Переглянути джерело

Fixed code example for setGravity() and removed references to earlier versions.

mitm 6 роки тому
батько
коміт
35f1a9179f
1 змінених файлів з 11 додано та 14 видалено
  1. 11 14
      src/docs/asciidoc/jme3/advanced/terrain_collision.adoc

+ 11 - 14
src/docs/asciidoc/jme3/advanced/terrain_collision.adoc

@@ -140,25 +140,18 @@ public class HelloTerrainCollision extends SimpleApplication
     RigidBodyControl with mass zero.*/
     terrain.addControl(new RigidBodyControl(0));
 
-    // We set up collision detection for the player by creating
-    // a capsule collision shape and a CharacterControl.
-    // The CharacterControl offers extra settings for
-    // size, stepheight, jumping, falling, and gravity.
-    // We also put the player in its starting position.
+    /**
+     * We set up collision detection for the player by creating
+     * a capsule collision shape and a CharacterControl.
+     * The CharacterControl offers extra settings for
+     * size, stepheight, jumping, falling, and gravity.
+     * We also put the player in its starting position.
+     */
     CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
     player = new CharacterControl(capsuleShape, 0.05f);
     player.setJumpSpeed(20);
     player.setFallSpeed(30);
 
-    //Some methods used for setting gravity related variables were deprecated in
-    //the 3.2 version of the engine. Choose the method that matches your version
-    //of the engine.
-    // < jME3.2
-    // player.setGravity(30f);
-
-    // >= jME3.2
-    player.setGravity(new Vector3f(0,-30f,0));
-
     player.setPhysicsLocation(new Vector3f(-10, 10, 10));
 
     // We attach the scene and the player to the rootnode and the physics space,
@@ -166,6 +159,10 @@ public class HelloTerrainCollision extends SimpleApplication
     bulletAppState.getPhysicsSpace().add(terrain);
     bulletAppState.getPhysicsSpace().add(player);
 
+    // You can change the gravity of individual physics objects after they are
+    // added to the PhysicsSpace.
+    player.setGravity(new Vector3f(0,-30f,0));
+
   }
   /** We over-write some navigational key mappings here, so we can
    * add physics-controlled walking and jumping: */