One of the reasons why you extend SimpleApplication
is that basic camera navigation (WASD keys and MouseLook) is already preconfigured. But when you run the PhysicsTown
sample, you notice that the first-person camera keeps running straight through walls. Have we not just added a RigidBodyControl
to the model to make the town solid?
We have, but the camera is not a solid object yet. The default navigation of SimpleApplication
uses the non-physical setLocalTranslation()
method to move the camera. To make this sample work, we first need to define a so-called collision shape for the invisible player, since the camera object has no mesh. We also update the keyboard navigation to use physics-aware methods.
Return to PhysicsTown.java
and perform the following steps:
In the
simpleInitApp()
method, create aplayerNode
. In this demo, our player is an invisible first-person character, but you could also attach a model to this node.private Node playerNode; public...