Haxe - Find if RigidBody is moving, and if it is colliding

Hi!

I’m trying to create a 3D platformer prototype using a cube with a rigid body as the “player character”. I want to prevent the cube from jumping while it is in mid-air.

How can I find if a rigid body is moving (I tried using GetLinearVelocity.Z but it is never zero, even when the cube is stopped)?

Alternatively, how can I check if the rigid body is currently colliding with stuff?

2 Likes

Hi guys, any ideas on how to achieve this?

Try looking at examples code.
You can check speed with maths (distance moved/time unit)

1 Like

You can try to use getContacts(); to check if it colliding with an rigidbody.

1 Like

I struggled a lot too, altho, I found out that if you put a small cube that’s under your character and it’s not touching it and set it to trigger mode and then change dynamic collision to static collision, on the nodes, send a ray from inside your character to the ground and check if its not the cube, the output result should be as a bool, going thru an IsTrue/IsFalse (Based on your object checking method). after that output, the last logic node and connect it to a set velocity.

1 Like

Thank you guys for your replies, now I’ll be able to do it! :slight_smile:

1 Like