Jump to content

Fly mode for characters


photo

Recommended Posts

Hello!

How can I tune character controls to enable "Fly mode"?

I want my char to free fly in this mode: for example, forward move direction is exact camera direction, not just XOY projection of it. I tryed

body.setGravity( 0 );

but I still can't control its height in this case.

So I think I need to rewrite states like CONTROLS_STATE_FORWARD or maybe use AUX states. How can I do this?

Link to comment

Try out one of the following:

  • Create physical PlayerActor, set gravity flag for its body to 0 (the actor should be simulated physically). This part is fine. After that:
    • Get user input with engine.controls.getState(CONTROLS_STATE_JUMP).
    • Right now your character is literally hanging in the air. That is why he cannot jump. You need to apply an impulse or force to his body that corresponds to user input.

    [*] If you do not need fully simulated physical character, you can use PlayerSpectator or PlayerSpectator + PlayerPersecutor for a third person character.

Link to comment
×
×
  • Create New...