Public Types | |
enum | Direction { Left = 1, Right = 2, Forward = 4, Backward = 8, Jump = 16, DirectionCount } |
Public Member Functions | |
Character (Object *object, World *world) | |
ctor | |
virtual | ~Character () |
dtor | |
bool | onGround () const |
virtual void | update (btScalar dt) |
Update the character position. | |
virtual void | move (int direction) |
Set movement direction (OR combination of movement directions). | |
void | setFallSpeed (btScalar fallSpeed) |
Set falling speed. | |
void | setJumpSpeed (btScalar jumpSpeed) |
Set jump speed. | |
void | setMaxJumpHeight (btScalar maxJumpHeight) |
Set maximum jump height. | |
bool | canJump () const |
void | jump () |
jump | |
Protected Member Functions | |
bool | fall (const btCollisionWorld *w, btScalar dt, const btVector3 &down) |
bool | recoverFromPenetration (const btCollisionWorld *collisionWorld) |
void | stepUp (const btCollisionWorld *collisionWorld) |
void | updateTargetPositionBasedOnCollision (const btVector3 &hit_normal, btScalar tangentMag=btScalar(0.0), btScalar normalMag=btScalar(1.0)) |
void | stepForwardAndStrafe (const btCollisionWorld *collisionWorld, const btVector3 &walkMove) |
void | stepDown (const btCollisionWorld *collisionWorld, btScalar dt) |
Protected Attributes | |
World * | m_world |
Object * | m_object |
bool | m_onGround |
int | m_directions |
btScalar | m_halfHeight |
btConvexShape * | m_shape |
btCollisionObject * | m_collisionObject |
btOverlappingPairCache * | m_pairCache |
btCollisionDispatcher * | m_dispatcher |
btScalar | m_fallSpeed |
btScalar | m_jumpSpeed |
btScalar | m_maxJumpHeight |
btScalar | m_turnAngle |
btScalar | m_walkVelocity |
btScalar | m_height |
btScalar | m_width |
btScalar | m_stepHeight |
btVector3 | m_currentPosition |
btVector3 | m_targetPosition |
bool | m_touchingContact |
btVector3 | m_touchingNormal |
Physics engine are great for collision, rigid body dynamics, soft body dynamics but they seldom provide a built in way of making characters move realistically, and Bullet is not exception to that rule.
The Character class allows an Object to be moved in the World simply and to collide with other objects in its path. It can be tuned to prevent the character from walking up to steep slopes, to change the falling speed, the walking speed, ...
ctor
object | Game object to manage | |
world | World in which the object evolves |
References Object::getBody(), World::getDynamicsWorld(), and World::removeObject().
bool Character::onGround | ( | ) | const |
void Character::move | ( | int | direction | ) | [virtual] |
Set movement direction (OR combination of movement directions).
bool Character::canJump | ( | ) | const |