Kaynağa Gözat

Merge pull request #325 from blackberry-gaming/next-sgrenier

Next sgrenier
Steve Grenier 13 yıl önce
ebeveyn
işleme
8375ade9bf

+ 9 - 0
gameplay/src/PhysicsCharacter.cpp

@@ -209,6 +209,15 @@ void PhysicsCharacter::setRightVelocity(float velocity)
     _rightVelocity = velocity;
 }
 
+Vector3 PhysicsCharacter::getCurrentVelocity() const
+{
+    Vector3 v(_currentVelocity.x(), _currentVelocity.y(), _currentVelocity.z());
+    v.x += _verticalVelocity.x();
+    v.y += _verticalVelocity.y();
+    v.z += _verticalVelocity.z();
+    return v;
+}
+
 void PhysicsCharacter::jump(float height)
 {
     // TODO: Add support for different jump modes (i.e. double jump, changing direction in air, holding down jump button for extra height, etc)

+ 7 - 0
gameplay/src/PhysicsCharacter.h

@@ -151,6 +151,13 @@ public:
      */
     void setRightVelocity(float velocity = 1.0f);
 
+    /**
+     * Returns the current velocity of the character.
+     *
+     * @return The current velocity.
+     */
+    Vector3 getCurrentVelocity() const;
+
     /**
      * Causes the character to jump to the specified height.
      *