First Person Character Troubles

How would you guys recommend creating a good first person character (control and physics wise). The way they have you do it in the tutorial(http://test.hub.jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_collision) works, but there must be some other way because with that you can still fly if you look up and hold up or look down and hold down. I was wondering if there was another object scheme or if it just requires that you add some extra programming on the current one. Thanks

Just don’t apply the walkDirection up and down if you don’t want to fly. Remove the y component of the vector before you apply them.

1 Like

the reason its doing it is because of the flycam, and pressing W for example tries to move in the direction the camera is facing, so if you face the sky it will try and move upwards and then gravity pulls you back down. You can disable the flycam (will also disable debug keys and debug text) by passing super(null) in the constructor of your class that extends SimpleApplication, and then add your own camera movement functionality, i suggest you look at the source of FlyByCamera.java for ideas.



Edit: or do normens idea :slight_smile:

1 Like

Before setting walk direction of the CharacterControl set it’s angle y to 0.

Example:



Vectorf3f dir = cam.getDirection();

dir.y = 0;

dir.normalize();

and then set the direction :slight_smile: