Просмотр исходного кода

Updated player controls for character sample to a 3rd person style camera.
Added PhysicsCharacter::getCurrentVelocity() method.

Steve Grenier 13 лет назад
Родитель
Сommit
9638f1b718
2 измененных файлов с 16 добавлено и 0 удалено
  1. 9 0
      gameplay/src/PhysicsCharacter.cpp
  2. 7 0
      gameplay/src/PhysicsCharacter.h

+ 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.
      *