panda3d.core.CollisionHandlerGravity

from panda3d.core import CollisionHandlerGravity
class CollisionHandlerGravity

Bases: CollisionHandlerPhysical

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.

Inheritance diagram

Inheritance diagram of CollisionHandlerGravity

__init__() → None
setOffset(offset: float) → None

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.

getOffset() → float

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.

setReach(reach: float) → None

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

getReach() → float

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

getAirborneHeight() → float

Return the height of the object from the ground.

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

See Also: is_in_outer_space()

isOnGround() → bool

Is the object at rest?

getImpactVelocity() → float

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 getImpactVelocity(). Normally I avoid polling, but we are calling isOnGround() frequently anyway.

getContactNormal() → LVector3
Return type

LVector3

addVelocity(velocity: float) → None

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.

setVelocity(velocity: float) → None

Sets the current vertical velocity.

getVelocity() → float

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: isOnGround() and getGravity()

setGravity(gravity: float) → None

Sets the linear gravity force (always plumb).

getGravity() → float

Gets the linear gravity force (always plumb).

setMaxVelocity(max_vel: float) → None

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.

getMaxVelocity() → float

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

setLegacyMode(legacy_mode: bool) → None

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

getLegacyMode() → bool

returns true if legacy mode is enabled

static getClassType() → TypeHandle
Return type

TypeHandle

property offset
Getter

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.

Setter

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.

Return type

float

property reach
Getter

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

Setter

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

Return type

float

property airborne_height

Return the height of the object from the ground.

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

See Also: is_in_outer_space()

Return type

float

property on_ground

Is the object at rest?

Return type

bool

property impact_velocity

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 getImpactVelocity(). Normally I avoid polling, but we are calling isOnGround() frequently anyway.

Return type

float

property contact_normal
Return type

LVector3

property velocity
Getter

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: isOnGround() and getGravity()

Setter

Sets the current vertical velocity.

Return type

float

property gravity
Getter

Gets the linear gravity force (always plumb).

Setter

Sets the linear gravity force (always plumb).

Return type

float

property max_velocity
Getter

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

Setter

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.

Return type

float