Detect RigidBody on ground

Since I’ve been having recurring issues with CharacterControl, I’ve decided to use RigidBodyControl for my character instead while I’m trying to download Minie.

How can I detect when the RigidBody hits the ground or its Y velocity is 0?

2 Likes

Yes, CharacterControl have many issues.

For a RB velocity there is method

1 Like

How can I detect when the RigidBody hits the ground or its Y velocity is 0?

If the ground is a physics object, you can use a downward raycast from the RigidBody to measure height above ground. Or you could use a collision listener to detect collisions between the RigidBody and the ground.

To get the Y velocity of a RigidBody, use rigidBody.getLinearVelocity(null).y

2 Likes

A downward raycast would probably do it.
Collision listening wouldn’t, because it would also detects x, y, and z collisions and I only want the downward y.
getLinearVelocity might work too, but I foresee problems with jumping up into a block…

For physics raycasting also remember to use certain CollisionGroups to avoid colliding with character itself or other not-needed-things. (tho i didnt used groups for it)

For node raycasting it would be some sub-node based to avoid same thing.