Jump to content

PlayerActor controls


photo

Recommended Posts

I use PlayerActor for first person game. Default behavior of PlayerActor is to JUMP - press E. I want to change default controls to my. I try use Unigine::Input::Control to load controls file, but I don't know how attach it to my PlayerActor instance.

 

Thanks.

Link to comment

I don't understand unigine architecture yet, so... I try use:

 

engine.controls.setStateKey(Controls::CONTROLS_STATE_JUMP, 32);

 

or I must get current player controls and do changes in it, like:

 

Controls controls = player.getControls(); // player is ActorPlayer instance

 

no one of variant is work (

Link to comment

I don't understand unigine architecture yet, so... I try use:

 

engine.controls.setStateKey(Controls::CONTROLS_STATE_JUMP, 32);

 

or I must get current player controls and do changes in it, like:

 

Controls controls = player.getControls(); // player is ActorPlayer instance

 

no one of variant is work (

 

Hello,

I would expect the first to have correctly linked the key to toggling the jump state.

Unless, you are overriding it by loading a control setup file after that call.

If that's all good, then, you should check to see the character is checking the control state to change its behavior.

 

Have you remembered to call the Character::update() function?

Link to comment

I try use Unigine::Input::Control to load controls file, but I don't know how attach it to my PlayerActor instance.

If you want to use Unigine::Input::Controls, you'll need to implement a layer that will map Unigine::Input::Actions into PlayerActor's controls.

See data/scripts/character/character_controls.h and Programming / High-level scripts / Input system article for reference.

 

I don't understand unigine architecture yet, so... I try use:

engine.controls.setStateKey(Controls::CONTROLS_STATE_JUMP, 32);

 

or I must get current player controls and do changes in it, like:

 

Controls controls = player.getControls(); // player is ActorPlayer instance

 

no one of variant is work (

Both of them work for me:

engine.controls.setState(CONTROLS_STATE_JUMP,1);

PlayerActor actor = new PlayerActor();
Controls controls = actor.getControls();
controls.setState(CONTROLS_STATE_JUMP,1);

But if you want to modify player's state it is better to use second version.

 

Have you remembered to call the Character::update() function?

This is necessary if you use our Character high-level script system (see data/scripts/character and Programming / High-level scripts / Character system article for reference)

Link to comment

Thanks a lot for answers, but... :)

 

If you want to use Unigine::Input::Controls, you'll need to implement a layer that will map Unigine::Input::Actions into PlayerActor's controls.

See data/scripts/character/character_controls.h and Programming / High-level scripts / Input system article for reference.

 

I don't know, want I to use Unigine::Input::Controls or not... I just want change buttons for my PlayerActor. I can't use key listener engine.controls.setKeyReleaseCallback() for update PlayerActor states directly with functions:

 

PlayerActor actor = new PlayerActor();
Controls controls = actor.getControls();
controls.setState(CONTROLS_STATE_JUMP,1);

 

cause PlayerActor have default keys behavior - E is JUMP. And I want to change E to SPACE;

 

I see data/scripts/character/character_controls.h, in class CharacterControlsHuman you use Character for player... I have not a character in my game, I have only a camera, is it right to use PlayerActor for it?

 

If I rewrite CharacterControlsHuman with PlayerActor instead Character, is it be correct practice? Or I must move some another way?

Link to comment

I just want change buttons for my PlayerActor. I can't use key listener engine.controls.setKeyReleaseCallback() for update PlayerActor states directly with functions:

 

PlayerActor actor = new PlayerActor();
Controls controls = actor.getControls();
controls.setState(CONTROLS_STATE_JUMP,1);

 

cause PlayerActor have default keys behavior - E is JUMP. And I want to change E to SPACE;

 

I see data/scripts/character/character_controls.h, in class CharacterControlsHuman you use Character for player... I have not a character in my game, I have only a camera, is it right to use PlayerActor for it?

 

If I rewrite CharacterControlsHuman with PlayerActor instead Character, is it be correct practice? Or I must move some another way?

 

1. You can just change default "jump" action in engine configuration globally. It can be done in Main menu window / Controls tab.

 

2. If it is not suitable for you and you want to override character actions, use input system from high-level scripts. In this case you need to set keys for jump and other actions in configuration file. And yes, you can implement something like CharacterControlsHuman for PlayerActor directly (without Unigine::Character).

 

It is right to use PlayerActor if you need first person camera.

Link to comment
×
×
  • Create New...