#include <PhysicsCharacter.h>
Classes | |
class | ActionInterface |
Public Member Functions | |
PhysicsCollisionObject::Type | getType () const |
bool | isPhysicsEnabled () const |
void | setPhysicsEnabled (bool enabled) |
float | getMaxStepHeight () const |
void | setMaxStepHeight (float height) |
float | getMaxSlopeAngle () const |
void | setMaxSlopeAngle (float angle) |
void | setVelocity (const Vector3 &velocity) |
void | setVelocity (float x, float y, float z) |
void | resetVelocityState () |
void | rotate (const Vector3 &axis, float angle) |
void | rotate (const Quaternion &rotation) |
void | setRotation (const Vector3 &axis, float angle) |
void | setRotation (const Quaternion &rotation) |
void | setForwardVelocity (float velocity=1.0f) |
void | setRightVelocity (float velocity=1.0f) |
Vector3 | getCurrentVelocity () const |
void | jump (float height, bool force=false) |
Protected Member Functions | |
btCollisionObject * | getCollisionObject () const |
Defines a physics controller class for a game character.
This can be used to control the movements and collisions of a character in a game. It interacts with the Physics system to apply gravity and handle collisions, however dynamics are not applied to the character directly by the physics system. Instead, the character's movement is controlled directly by the PhysicsCharacter class. This results in a more responsive and typical game character than would be possible if trying to move a character by applying physical simulation with forces.
btCollisionObject* gameplay::PhysicsCharacter::getCollisionObject | ( | ) | const [protected, virtual] |
Reimplemented from gameplay::PhysicsGhostObject.
Returns the current velocity of the character.
float gameplay::PhysicsCharacter::getMaxSlopeAngle | ( | ) | const |
Returns the maximum slope angle for the character.
The maximum slope angle determines the maximum angle of terrain that the character can walk on. Slopes with an angle larger than the specified angle will not allow the character to move on.
float gameplay::PhysicsCharacter::getMaxStepHeight | ( | ) | const |
Returns the maximum step height for the character.
PhysicsCollisionObject::Type gameplay::PhysicsCharacter::getType | ( | ) | const [virtual] |
Reimplemented from gameplay::PhysicsGhostObject.
bool gameplay::PhysicsCharacter::isPhysicsEnabled | ( | ) | const |
Returns whether physics simulation is enabled for the physics character.
void gameplay::PhysicsCharacter::jump | ( | float | height, |
bool | force = false |
||
) |
Causes the character to jump to the specified height.
height | The amount to jump. |
force | Set true to force the character to jump even if vertical velocity is non-zero |
Resets the internal velocity state which brings the character to an immediate stop
void gameplay::PhysicsCharacter::rotate | ( | const Vector3 & | axis, |
float | angle | ||
) |
Rotates the character.
axis | Axis of rotation. |
angle | Angle in radians. |
void gameplay::PhysicsCharacter::rotate | ( | const Quaternion & | rotation | ) |
Rotates the character.
rotation | Quaternion representing the rotation to apply. |
void gameplay::PhysicsCharacter::setForwardVelocity | ( | float | velocity = 1.0f | ) |
Moves the character forward with the given velocity vector.
The forward velocity is defined by the character's current orientation (it is the forward vector from the character's current world transform).
Note that a negative velocity (i.e. -1.0f) will move the character backwards.
velocity | Optional velocity modifier. |
void gameplay::PhysicsCharacter::setMaxSlopeAngle | ( | float | angle | ) |
Sets the maximum slope angle (in degrees).
angle | The maximum slope angle. |
void gameplay::PhysicsCharacter::setMaxStepHeight | ( | float | height | ) |
Sets the maximum step height for the character.
height | The maximum step height. |
void gameplay::PhysicsCharacter::setPhysicsEnabled | ( | bool | enabled | ) |
Enables or disables physics simulation for the character.
When physics simulation is enabled (default), the physics character automatically responds to collisions in the physics world. For example, the character will automatically slide along walls, step up stairs, react to gravity, etc.
When disabled, the character will not have any physics applied on it and will therefore be allowed to walk through walls, ceiling, floors, other objects, etc.
enabled | true to enable physics simulation, false otherwise. |
void gameplay::PhysicsCharacter::setRightVelocity | ( | float | velocity = 1.0f | ) |
Moves the character right with the given velocity vector.
The right velocity is defined by the character's current orientation (it is the right vector from the character's current world transform).
Note that a negative velocity (i.e. -1.0f) will move the character left.
velocity | Optional velocity modifier. |
void gameplay::PhysicsCharacter::setRotation | ( | const Vector3 & | axis, |
float | angle | ||
) |
Sets the rotation of the character.
axis | Axis of rotation. |
angle | Angle in radians. |
void gameplay::PhysicsCharacter::setRotation | ( | const Quaternion & | rotation | ) |
Sets the rotation of the character.
rotation | Quaternion representing the new rotation. |
void gameplay::PhysicsCharacter::setVelocity | ( | const Vector3 & | velocity | ) |
Sets the velocity of the character.
Calling this function sets the velocity (speed and direction) for the character. The velocity is maintained until this method is called again. The final velocity of the character is determined by product of the current velocity, right and forward vectors.
velocity | Movement velocity. |
void gameplay::PhysicsCharacter::setVelocity | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the velocity of the character.
Calling this function sets the velocity (speed and direction) for the character. The velocity is maintained until this method is called again. The final velocity of the character is determined by product of the current velocity, right and forward vectors.
x | The x coordinate of the velocity vector. |
y | The y coordinate of the velocity vector. |
z | The z coordinate of the velocity vector. |