|
|
@@ -16,7 +16,7 @@ You use a `RigidBodyControl` for the static collidable scene, and a `CharacterCo
|
|
|
You can use the solution shown here for first-person shooters, mazes, and similar games.
|
|
|
|
|
|
|
|
|
-image::jme3/beginner/beginner-scene.png[beginner-scene.png,with="360",height="281",align="center"]
|
|
|
+image::jme3/beginner/beginner-scene.png[beginner-scene.png,360,281,align="center"]
|
|
|
|
|
|
|
|
|
|
|
|
@@ -307,7 +307,10 @@ To use collision detection, you add a RigidBodyControl to the `sceneModel` Spati
|
|
|
* Add the control to the Spatial to give it physical properties.
|
|
|
* As always, attach the sceneModel to the rootNode to make it visible.
|
|
|
|
|
|
-*Tip:* Remember to add a light source so you can see the scene.
|
|
|
+[TIP]
|
|
|
+====
|
|
|
+Remember to add a light source so you can see the scene.
|
|
|
+====
|
|
|
|
|
|
|
|
|
=== The Physics-Controlled Player
|
|
|
@@ -482,21 +485,26 @@ This is how the walking is triggered:
|
|
|
. Initialize the vector `walkDirection` to zero. This is where you want to store the calculated walk direction.
|
|
|
.. Add to `walkDirection` the recent motion vectors that you polled from the camera. This way it is posible for a character to move forward and to the left simultaneously, for example!
|
|
|
.. This one last line does the “walking magic:
|
|
|
++
|
|
|
[source,java]
|
|
|
----
|
|
|
player.setWalkDirection(walkDirection);
|
|
|
----
|
|
|
-
|
|
|
- Always use `setWalkDirection()` to make a physics-controlled object move continuously, and the physics engine handles collision detection for you.
|
|
|
++
|
|
|
+Always use `setWalkDirection()` to make a physics-controlled object move continuously, and the physics engine handles collision detection for you.
|
|
|
|
|
|
.. Make the first-person camera object follow along with the physics-controlled player:
|
|
|
++
|
|
|
[source,java]
|
|
|
----
|
|
|
cam.setLocation(player.getPhysicsLocation());
|
|
|
----
|
|
|
|
|
|
|
|
|
-*Important:* Again, do not use `setLocalTranslation()` to walk the player around. You will get it stuck by overlapping with another physical object. You can put the player in a start position with `setPhysicalLocation()` if you make sure to place it a bit above the floor and away from obstacles.
|
|
|
+[IMPORTANT]
|
|
|
+====
|
|
|
+Again, do not use `setLocalTranslation()` to walk the player around. You will get it stuck by overlapping with another physical object. You can put the player in a start position with `setPhysicalLocation()` if you make sure to place it a bit above the floor and away from obstacles.
|
|
|
+====
|
|
|
|
|
|
|
|
|
== Conclusion
|