eugene.litvinov Posted March 24, 2011 Posted March 24, 2011 We use PlayerActor, Unigine::Input::Control and ControlsDummy bunch for our game's player. We need realize next functionality: decrease controllability when player is jumping (now our player (and player from unigine script character system too) have the same controllability in ground and in jump states, so we can change jumping direction in air). For example, if in ground player have 100% keyboard response, then in air it must have, for example, 10% keyboard response. I try achieve this with adding forces to PlayerActor's Body, but this is no good pattern... I think I need influence on player's controls, but I don't know how. I try to decrease max parameter in controls_def xml, but this is no decrease keyboard response. Any ideas? Thanks
Guest anet Posted March 25, 2011 Posted March 25, 2011 We use PlayerActor, Unigine::Input::Control and ControlsDummy bunch for our game's player. We need realize next functionality: decrease controllability when player is jumping (now our player (and player from unigine script character system too) have the same controllability in ground and in jump states, so we can change jumping direction in air). For example, if in ground player have 100% keyboard response, then in air it must have, for example, 10% keyboard response. I try achieve this with adding forces to PlayerActor's Body, but this is no good pattern... I think I need influence on player's controls, but I don't know how. I try to decrease max parameter in controls_def xml, but this is no decrease keyboard response. Any ideas? Thanks Try to tweak device_change_speed and device_return_speed input parameters. You can do this in xml config file: <input device="Keyboard" state="32" device_change_speed = "0.5" device_return_speed = "0.5"/> Or using Unigine::Input::Input methods: void Unigine::Input::Input::setChangeSpeed(float) void Unigine::Input::Input::setReturnSpeed(float) Both of this parameters are INFINITY by default.
eugene.litvinov Posted March 28, 2011 Author Posted March 28, 2011 It seems like Input can work only with two states: == 0 - player isn't controllable; > 0 - player is controllable like with INFINITY. I try set setChangeSpeed(0.1) and setReturnSpeed(0.1) - this has no effect
Guest anet Posted March 28, 2011 Posted March 28, 2011 It seems like Input can work only with two states: == 0 - player isn't controllable; > 0 - player is controllable like with INFINITY. I try set setChangeSpeed(0.1) and setReturnSpeed(0.1) - this has no effect If you are talking about high-level character script then this happens because of the following code: action1 = control.getAction("move_forward"); controls_dummy.setState(CONTROLS_STATE_FORWARD,action1.getState() != action1.getNeutral()); As you can see this code does not take into account exact state value. It moves character even if state value is 0.1. But if I change the code this way: action1 = control.getAction("move_forward"); controls_dummy.setState(CONTROLS_STATE_FORWARD,action1.getState() == action1.getMax()); It waits until state value becomes 1.0 before moving character forward. Another way is to change input device threshold using the following method: void Unigine::Input::Input::setThreshold(float device_threshold_); or by changing threshold attribute in the input tag: <input device="Keyboard" state="115" threshold="0.5"/> If you change device threshold attribute input returns non-neutral value only after its state exceeds the threshold.
eugene.litvinov Posted March 31, 2011 Author Posted March 31, 2011 Thanks, for deployed answer. I change code to your: action1 = control.getAction("move_forward"); controls_dummy.setState(CONTROLS_STATE_FORWARD,action1.getState() == action1.getMax()); But it not quite, that I need, see screenshot: It illustrates, that if we start press right ley (in screen above I mistake - right instead left key), then player not move until Unigine::Input::Action not get it max threshold. So we have curve, like in screenshot. I need a bit different behavior: Is a possible way to decrease keyboard action on player? I need pass to player not all velocity, but only a part, something like this pseudo-code: PLAYER_MOVEMENT_POWER = KEYBOAR_ACTION * 0.1; // when player is jumping PLAYER_MOVEMENT_POWER = KEYBOAR_ACTION; // default
Guest anet Posted March 31, 2011 Posted March 31, 2011 Is a possible way to decrease keyboard action on player? I need pass to player not all velocity, but only a part, something like this pseudo-code: PLAYER_MOVEMENT_POWER = KEYBOAR_ACTION * 0.1; // when player is jumping PLAYER_MOVEMENT_POWER = KEYBOAR_ACTION; // default Player controls' states can only be on or off. So, if you need to move the character you should set appropriate controls states to 1 like in the original version of character script: action1 = control.getAction("move_forward"); controls_dummy.setState(CONTROLS_STATE_FORWARD,action1.getState() != action1.getNeutral()); To decrease player's sensitivity I would change character's speed: ground = actor.getGround(); if(ground == 0) { actor.setMinVelocity(min_jump_velocity); } else { actor.setMinVelocity(min_velocity); } where min_jump_veloicty = min_velocity * 0.1f
eugene.litvinov Posted March 31, 2011 Author Posted March 31, 2011 To decrease player's sensitivity I would change character's speed: I used this pattern, but in this case player lose his velocity, that he has, for example, when run, and then, when he jump his max velocity truncate and he is not jump in his direction. So I must save starting velocity of jump and decrease new control actions.
Guest anet Posted April 4, 2011 Posted April 4, 2011 I used this pattern, but in this case player lose his velocity, that he has, for example, when run, and then, when he jump his max velocity truncate and he is not jump in his direction. So I must save starting velocity of jump and decrease new control actions. Try to decrease player actor's acceleration.
eugene.litvinov Posted April 7, 2011 Author Posted April 7, 2011 Try to decrease player actor's acceleration. Thanks, it works!
Recommended Posts