How can I blueprint coordinates that are consistently directly behind the player?

I’ve not done this kind of math in a long time, and this is proving difficult for me and I feel I’m missing something obvious.

My player controls a ground vehicle, moving across the X and Y axis. Let’s say he’s facing X axis forward, which I believe is vector X: 1, Y: 0 ? If I get actor location, break it into a vector, and subtract 300 from the X axis and place an object there, well hey presto, the object is where I expect it to be! Now, though, my player rotates 90 degrees so that he is traveling along the Y axis. Now my object is to the player’s right and not just behind him, because from this angle 300 needs to be subtracted from the Y axis to place the object behind them.

Am I doing something completely wrong here, or am I just missing something? I’ve been playing with fitting the player vector and/or rotation into the equation, because that feels naturally intuitive, but I can’t figure out how to apply the player vector (or rotation) to the player location to give me a map location in X, Y, Z coordinates that is consistently behind the player regardless of his rotation.

Thanks for your time! :slight_smile:

Actor has a method called GetActorForwardVector() that should be available in Blueprints. This will return a vector pointing forward using the Actors rotation (by assuming positive X is the default forward direction). If you multiply this vector with -1 it will instead be pointing backward from the Actor.

If you take this Backwards vector and add it to the Actors location you will get a new location that is behind the Actor. The Forward vector will probably have length 1 (or close to it) so you may want to multiply the Backwards vector with a number to increase the distance behind the Actor.

Absolutely PERFECT. Thank you so much! I had no idea at all I could multiply the vector like that, but it makes perfect sense now. The code is working perfectly, sincere thanks. :slight_smile: