- Home /
How to detect if object is moving forwards
I need a script that detects when an object has moved forwards in the direction it was facing. The object has a rigidbody and a box collider. Please help
Answer by James_BadAlchemy · Nov 02, 2018 at 06:33 AM
You can reference your rigidbody for this information. Check to see if your rigidbody.velocy = vector3.zero, if not, Then you're moving.
As for if they're moving forwards, It kinda depends on your set up. Is it 2D or 3D? Is it moving forwards relative to a camera or other system?
It is a 3D game but the object is not the player it is just an AI I have made wander around randomly but for some reason, the animation syntax doesn't work in that script so I made a second script. I need the second script to detect when the AI is moving (not rotating). This is so I can run the animation I need. Can you please help.
P.S. an example script would be greatly helpful
Answer by NerdIt- · Nov 02, 2018 at 11:48 PM
@James_BadAlchemy. It is a 3D game but the object is not the player it is just an AI I have made wander around randomly but for some reason, the animation syntax doesn't work in that script so I made a second script. I need the second script to detect when the AI is moving (not rotating). This is so I can run the animation I need. Can you please help.
P.S. an example script would be very helpful
Your answer

Follow this Question
Related Questions
Object moves to 0,0,0? (Just want to know why it works) 1 Answer
Vector3.Lerp not working? 5 Answers
WALL collision detection problem... help!!!! 0 Answers
Game Object not moving in Canvas 0 Answers
gameObject moves twice? 0 Answers