I want the player being affected by all physics, like gravitation, collisions, materials etc, but iam confused how to implement this.
If the player is a ball and there is a chase cam, it is relatively simple, by setting the velocity of the "player" int the correct directions.
But i don't know how to map first person shooter handling on a physics node - whats the best way?
I would attach the camera to the physics node, eventually with a joint (it may not be affected to angular velocity (?) )
The physicsnode should have a material with x friction and a low center point of mass (A physicsBox tipped always over with my tests)
But how could you apply the movements of the mouse / keystrokes to that node?
Iam thinking about that, because i only want jme's collisions system be used when its really needed (like picking) - so why doing another collision detection if theres smth, which does it every frame?
Simply attach your camera via a CameraNode to the player representation. Then apply forces to the players physics instead of setting position or velocity. Figuring out the correct forces for smooth gameplay is going to be tough, though.
While testing this approach, i found a Bug in DynamicPhysicsImpl at line 168:
body.addForceAtRelPos( force.x, force.y, force.y, at.x, at.y, at.z );
shouldn't be the second force.y named force.z ? :)
I wondered, why i couldn't apply a force in z-direction.
If i understood correctly, the addForce only adds the force for the next step, after calculating the step the force will be removed? Or if applied once, it will be ever on a body and must be removed with physicsNode.clearForce() ?
whoops y/z corrected, thanks!
You understood correctly - the force does not need to be set back to 0. I have added a javadoc comment on it.