Browse Source

Merge pull request #1671 from louis-mclaughlin/player_velocity_patch

Added ability to bring physics character to an immediate stop
Sean Taylor 11 years ago
parent
commit
d68f92bfb5
2 changed files with 16 additions and 0 deletions
  1. 10 0
      gameplay/src/PhysicsCharacter.cpp
  2. 6 0
      gameplay/src/PhysicsCharacter.h

+ 10 - 0
gameplay/src/PhysicsCharacter.cpp

@@ -191,6 +191,16 @@ void PhysicsCharacter::setVelocity(float x, float y, float z)
     _moveVelocity.setValue(x, y, z);
 }
 
+void PhysicsCharacter::resetVelocityState()
+{
+    _forwardVelocity = 0.0f;
+    _rightVelocity = 0.0f;
+    _verticalVelocity.setZero();
+    _currentVelocity.setZero();
+    _normalizedVelocity.setZero();
+    _moveVelocity.setZero();
+}
+
 void PhysicsCharacter::rotate(const Vector3& axis, float angle)
 {
     GP_ASSERT(_node);

+ 6 - 0
gameplay/src/PhysicsCharacter.h

@@ -113,6 +113,12 @@ public:
      */
     void setVelocity(float x, float y, float z);
 
+    /**
+     * Resets the internal velocity state which brings the character to an immediate stop
+     *
+    */
+    void resetVelocityState();
+
     /**
      * Rotates the character.
      *