|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Member Functions | Protected Member Functions
gameplay::PhysicsCharacter Class Reference

`#include <PhysicsCharacter.h>`

Inheritance diagram for gameplay::PhysicsCharacter:

List of all members.

## 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

## Detailed Description

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.

See also:
  http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-Collision_Objects

## Member Function Documentation

btCollisionObject* gameplay::PhysicsCharacter::getCollisionObject | ( |  | ) | const`[protected, virtual]`

See also:
  PhysicsCollisionObject::getCollisionObject

Reimplemented from gameplay::PhysicsGhostObject.

Vector3 gameplay::PhysicsCharacter::getCurrentVelocity | ( |  | ) | const

Returns the current velocity of the character.

Returns:
  The current velocity.

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.

Returns:
  The maximum slope angle.

float gameplay::PhysicsCharacter::getMaxStepHeight | ( |  | ) | const

Returns the maximum step height for the character.

Returns:
  The maximum step height.

PhysicsCollisionObject::Type gameplay::PhysicsCharacter::getType | ( |  | ) | const`[virtual]`

See also:
  PhysicsCollisionObject::getType

Reimplemented from gameplay::PhysicsGhostObject.

bool gameplay::PhysicsCharacter::isPhysicsEnabled | ( |  | ) | const

Returns whether physics simulation is enabled for the physics character.

Returns:
  true if physics simulation is enabled, false otherwise.

See also:
  setPhysicsEnabled(bool)

void gameplay::PhysicsCharacter::jump | ( | float | height,
|  | bool | force = `false`
| ) |  |

Causes the character to jump to the specified height.

Parameters:

  height | The amount to jump.
  force | Set true to force the character to jump even if vertical velocity is non-zero

void gameplay::PhysicsCharacter::resetVelocityState | ( |  | ) |

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.

Parameters:

  axis | Axis of rotation.
  angle | Angle in radians.

void gameplay::PhysicsCharacter::rotate | ( | const Quaternion & | rotation | ) |

Rotates the character.

Parameters:

  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.

Parameters:

  velocity | Optional velocity modifier.

void gameplay::PhysicsCharacter::setMaxSlopeAngle | ( | float | angle | ) |

Sets the maximum slope angle (in degrees).

Parameters:

  angle | The maximum slope angle.

void gameplay::PhysicsCharacter::setMaxStepHeight | ( | float | height | ) |

Sets the maximum step height for the character.

Parameters:

  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.

Parameters:

  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.

Parameters:

  velocity | Optional velocity modifier.

void gameplay::PhysicsCharacter::setRotation | ( | const Vector3 & | axis,
|  | float | angle
| ) |  |

Sets the rotation of the character.

Parameters:

  axis | Axis of rotation.
  angle | Angle in radians.

void gameplay::PhysicsCharacter::setRotation | ( | const Quaternion & | rotation | ) |

Sets the rotation of the character.

Parameters:

  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.

Parameters:

  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.

Parameters:

  x | The x coordinate of the velocity vector.
  y | The y coordinate of the velocity vector.
  z | The z coordinate of the velocity vector.

All Classes Functions Variables Typedefs Enumerations Enumerator