Jump to content

IG Debug mode, changing the velocity of the free-flying spectator


photo

Recommended Posts

Hi, this should be a rather simple feature: we need to change at runtime the velocity of the free-flying spectator (when ig_debug=1 and 'F' has been pressed).

How can we *safely* detect if the free-flying spectator is being used? Is there any API?
At the moment, I'm doing "if (auto p = checked_ptr_cast<PlayerSpectator>(Game::getPlayer()))" but it doesn't feel future proof nor compatible in the case we use our own spectator for other things.
Also, in this case, p->getMinVelocity() and p->getMaxVelocity() always return 0. Strange. Although we still can set the velocity with p->setMin/MaxVelocity()

Rationale for the feat.: we have huuuge terrains, and small details inside controlled by IG. So we need to be able to move very slow, slow, fast, and very very fast.... Controlling the velocity with  the mouse wheel would be a good idea to try.

Thanks!

Link to comment

Hello! 
You can try the following approach to change the speed:

int is_debug_player = false;

int AppSystemLogic::update()
{
	if (IG::Manager::get()->isDebugEnabled() && !Console::isActive())
	{
		if (Input::isKeyDown(Input::KEY_F))
			is_debug_player = true;
		if (Input::isKeyDown(Input::KEY_G))
			is_debug_player = false;

		if (is_debug_player)
		{
			PlayerSpectatorPtr player = checked_ptr_cast<PlayerSpectator>(Game::getPlayer());
			if (player)
			{
				if (Input::isKeyDown(Input::KEY_DIGIT_1))
				{
					player->setMinVelocity(5); // usual speed
					player->setMaxVelocity(10); // speed with SHIFT
				}
				if (Input::isKeyDown(Input::KEY_DIGIT_2))
				{
					player->setMinVelocity(50);
					player->setMaxVelocity(100);
				}
				if (Input::isKeyDown(Input::KEY_DIGIT_3))
				{
					player->setMinVelocity(500);
					player->setMaxVelocity(1000);
				}
			}
			else
			{
				is_debug_player = false;
			}
		}
	}
	else
	{
		is_debug_player = false;
	}
	return 1;
}

 

also It might be better in your case to use your own debug player with different settings for different case. 

  • Thanks 1
Link to comment
×
×
  • Create New...