Jump to content

[SOLVED] Disable Engine Controls


photo

Recommended Posts

Hi,

I am playing around with the custom control bindings in the VR template but there seems to be conflicts between the Engine defined controls and the controls in the VRPlayerPC template. Both the 'e' button the the space key cause the player to jump. I would like to use the 'e' key for my own functions, but because the engine has defined it in the control settings to be for jump, the program now does both my custom function and jump at the same time.

I tried to rebind the controls in the editor so that jump is also bound to the space button, however if I save and restart the editor the button configs are reset, and the changes do not propagate in-game.

I can't seem to find in the documentation the recommended way to handle this. Any suggestions?

Thanks :)

Link to comment

Hello @vcapote!

Yes, the VR Template shows an example of manual handling of keys pressed in the application window and changing the states of the player. Here is a piece of code from VRPlayerPC.cpp:

void VRPlayerPC::controls_update()
{
	int jump = 0;
/*..*/
	if (app->clearKeyState(' ')) { jump = 1; keyboard_used = 1; }
/*..*/
	controls->setState(Controls::STATE_JUMP, jump);
/*..*/
}

The Application Controls (bindings to them can be found and set in the engine System Menu) are controlled by the ControlsApp class. There are default bindings, that's why the jumping action appears to be controlled by different keys at the same time.

Simply call the setEnabled(0) to disable input handling for current application window:

void VRPlayerPC::init()
{
	/*..*/
	ControlsApp *controls_app = ControlsApp::get();
	controls_app->setEnabled(0);
}

But in this case you'll have to process mouse events manually.

The solution here is to redefine the application jump control binding:

void VRPlayerPC::init()
{
	/*..*/
	ControlsApp *controls_app = ControlsApp::get();
	controls_app->setStateKey(Controls::STATE_JUMP, ' ');
}


void VRPlayerPC::controls_update()
{
	/*..*/
		// there is no need to use this detection anymore, so you can comment it out
	// if (app->clearKeyState(' ')) { jump = 1; keyboard_used = 1; }
}

After that, you'll have only one appropriate key for jumping. You can also take a look at our Getting and Managing User Inputs article of Programming Quick Start.

Hope I've managed to make it clear for you.

Thank you!

PS.

20 hours ago, vcapote said:

I tried to rebind the controls in the editor so that jump is also bound to the space button, however if I save and restart the editor the button configs are reset, and the changes do not propagate in-game.

The control settings of the Editor cover only its controls, they have no influence on the application ones.

  • Like 1
Link to comment
  • morbid changed the title to [SOLVED] Disable Engine Controls
×
×
  • Create New...