[SOLVED] Trigger an event when entity is in motion

I need to trigger an animation when my player entity moves.
I’ve tried many times but I can’t get anything to work.

I figured it out you just have to make 4 if statements that do the same thing then put in

if (this.entity.rigidbody.linearVelocity.x >= 0.1)
if (this.entity.rigidbody.linearVelocity.x <= -0.1)
if (this.entity.rigidbody.linearVelocity.z >= 0.1)
if (this.entity.rigidbody.linearVelocity.z <= -0.1)

1 Like

If you just need to know if something is having any velocity its possible to do this instead to save on redundant code.

if(this.entity.rigidbody.linearVelocity.length() > 0.1)
1 Like

I tried that and couldn’t get it to work although I realised that a could just call the run function on an event called by my movement script which made the code much easier