Download

How to tell if an actor is moving backwards or forwards?

Does anyone know how to tell if an actor is moving forwards or backwards relative to their rotation, even if it’s a speed in positive & negative numbers for forwards & backwards?

I’ve tried using Velocity and Forward Vector but I can’t seem to do anything with the data to get that result.

Thanks :slight_smile:

If you take the dot product of the normalized velocity vector and the forward vector, the result will be near positive 1 when moving forwards (relative actor rotation) and near negative 1 when moving backwards:

9e0ca97b77b0552b3dddc3a67eed3fbfe09829bd.png

The float output at the end is what you’re after. Technically you could skip the normalization and then just check if the output is larger than zero (forward), or less than zero (backward), but you would probably want to allow for some noise in the results. For example, a result of 0.00004359758 or something probably means you’re not really moving noticeably at all rather than definitely forwards, even though it’s technically larger than zero.

Thank you very much :slight_smile:

thanks.

this helped me today. so simple to get in the end.

Yup dot product is great for this.

To test use “nearly equal” node. Value of .95 is forward enough for human brain when it interprets directions.