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?
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?
Yes, CharacterControl have many issues.
For a RB velocity there is method
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
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.