Is there a way to check if an object is moving toward (or away from) the direction of its local x axis? In other words, toward (or away from) transform.right? Regardless of which way the object is oriented?
I am wondering if transform.InverseTransformDirection (or InverseTransformVector) could do this for me, but I honestly don’t understand how those work.
(Why do I ask? I am programming an automatic full stop feature for a spaceship. It needs to know which way the ship is drifting so it can AddRelativeForce in the opposite direction. Focusing on just the x axis right now. I have already tried using the velocity vector – if velocity.x > 0 then add negative relative force, if velocity.x < 0 then add positive relative force, etc. That works fine if the ship is facing forward in world space, between -90 and 90 on the y axis. But facing backwards, it gets all messed up because drifting in a negative direction according to the velocity vector is actually drifting in a positive direction according to the object’s local transform. To handle this (checking the eulerAngles to see which way the object is oriented), the code becomes complicated and unreliable, especially if the ship is moving along other axes at the same time. So I want to know if I can simply check for movement toward or away from the object’s local transform.right.)
Thanks.