Panda3D
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Public Member Functions | Static Public Member Functions
CollisionHandlerGravity Class Reference

A specialized kind of CollisionHandler that sets the Z height of the collider to a fixed linear offset from the highest detected collision point each frame. More...

Inheritance diagram for CollisionHandlerGravity:
CollisionHandlerPhysical CollisionHandlerEvent CollisionHandler TypedReferenceCount TypedObject ReferenceCount

List of all members.

Public Member Functions

 CollisionHandlerGravity ()
 addVelocity (float velocity)
 Adds the sepcified amount to the current velocity.
float getAirborneHeight ()
 Return the height of the object from the ground.
Vec3 const getContactNormal ()
float getGravity ()
 Gets the linear gravity force (always plumb).
float getImpactVelocity ()
 How hard did the object hit the ground.
bool getLegacyMode ()
 returns true if legacy mode is enabled
float getMaxVelocity ()
 Retrieves the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second.
float getOffset ()
 Returns the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider.
float getReach ()
 Returns the reach to add to (or subtract from) the highest collision point.
float getVelocity ()
 Gets the current vertical velocity.
bool isOnGround ()
 Is the object at rest?
 setGravity (float gravity)
 Sets the linear gravity force (always plumb).
 setLegacyMode (bool legacy_mode)
 Enables old behavior required by Toontown (Sellbot Factory lava room is good test case, lava and conveyor belt specifically).
 setMaxVelocity (float max_vel)
 Sets the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second.
 setOffset (float offset)
 Sets the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider.
 setReach (float reach)
 Sets the reach to add to (or subtract from) the highest collision point.
 setVelocity (float velocity)
 Sets the current vertical velocity.

Static Public Member Functions

static TypeHandle getClassType ()

Detailed Description

A specialized kind of CollisionHandler that sets the Z height of the collider to a fixed linear offset from the highest detected collision point each frame.

It's intended to implement walking around on a floor of varying height by casting a ray down from the avatar's head.


Constructor & Destructor Documentation


Member Function Documentation

addVelocity ( float  velocity)

Adds the sepcified amount to the current velocity.

This is mostly here allow this common operation to be faster for scripting, but it's also more concise even in cpp.

float getAirborneHeight ( )

Return the height of the object from the ground.

The object might not necessarily be at rest. Use is_on_ground() if you want to know whether the object is on the ground and at rest.

See Also: is_in_outer_space()

static TypeHandle getClassType ( ) [static]

Reimplemented from CollisionHandlerPhysical.

float getGravity ( )

Gets the linear gravity force (always plumb).

float getImpactVelocity ( )

How hard did the object hit the ground.

This value is set on impact with the ground. You may want to watch (poll) on is_on_groun() and when that is true, call get_impact_velocity(). Normally I avoid polling, but we are calling is_on_ground() frequently anyway.

bool getLegacyMode ( )

returns true if legacy mode is enabled

float getMaxVelocity ( )

Retrieves the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second.

See set_max_velocity().

float getOffset ( )

Returns the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider.

float getReach ( )

Returns the reach to add to (or subtract from) the highest collision point.

float getVelocity ( )

Gets the current vertical velocity.

Generally, negative values mean the object is in free fall; while postive values mean the object has vertical thrust.

A zero value does not necessarily mean the object on the ground, it may also be weightless and/or at the apex of its jump.

See Also: is_on_ground() and get_gravity()

bool isOnGround ( )

Is the object at rest?

setGravity ( float  gravity)

Sets the linear gravity force (always plumb).

setLegacyMode ( bool  legacy_mode)

Enables old behavior required by Toontown (Sellbot Factory lava room is good test case, lava and conveyor belt specifically).

Behavior is to throw enter/exit events only for floor that the toon is in contact with

setMaxVelocity ( float  max_vel)

Sets the maximum speed at which the object will be allowed to descend towards a floor below it, in units per second.

Set this to zero to allow it to instantly teleport any distance.

setOffset ( float  offset)

Sets the linear offset to add to (or subtract from) the highest detected collision point to determine the actual height at which to set the collider.

setReach ( float  reach)

Sets the reach to add to (or subtract from) the highest collision point.

setVelocity ( float  velocity)

Sets the current vertical velocity.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties