Browse Source

Merge pull request #1668 from louis-mclaughlin/force_jump_patch

Added ability to force physics character to jump even if vertical veloci...
Sean Taylor 11 years ago
parent
commit
3e5e21d5d3
2 changed files with 4 additions and 3 deletions
  1. 2 2
      gameplay/src/PhysicsCharacter.cpp
  2. 2 1
      gameplay/src/PhysicsCharacter.h

+ 2 - 2
gameplay/src/PhysicsCharacter.cpp

@@ -234,10 +234,10 @@ Vector3 PhysicsCharacter::getCurrentVelocity() const
     return v;
 }
 
-void PhysicsCharacter::jump(float height)
+void PhysicsCharacter::jump(float height, bool force)
 {
     // TODO: Add support for different jump modes (i.e. double jump, changing direction in air, holding down jump button for extra height, etc)
-    if (!_verticalVelocity.isZero())
+    if (!force && !_verticalVelocity.isZero())
         return;
 
     // v = sqrt(v0^2 + 2 a s)

+ 2 - 1
gameplay/src/PhysicsCharacter.h

@@ -178,8 +178,9 @@ public:
      * Causes the character to jump to the specified height.
      *
      * @param height The amount to jump.
+     * @param force Set true to force the character to jump even if vertical velocity is non-zero
      */
-    void jump(float height);
+    void jump(float height, bool force = false);
 
 protected: