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.
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:
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.
Hi. I know this is a really old thread, but, I’m having problems with this solution in that, it only works when my pawn is facing a certain direction in the world. If I turn around then the 1 and -1 are inverted. I’m probably doing something wrong, but, could you explain what nodes I need for this setup with the Dot Product node. What is a “normalized velocity vector”?
My setup is
Get Actor Location - Dot Product Top Pin,
Get Velocity (self) - Dot Product Bottom Pin.
Although I’ve tried switching the pins around, I can’t get the 1 / -1 values to be consistent with the rotation of the pawn. I’ve also played around with ‘Get Forward Vector’ but had no joy. Any help would be appreciated