Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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! :)

Product Version: Not Selected
more ▼

asked Jun 16 '14 at 02:58 AM in Blueprint Scripting

avatar image

45 7 11 14

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Jun 16 '14 at 07:57 AM

avatar image

1.2k 27 22 211

avatar image Spinkler Jun 16 '14 at 08:15 AM

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. :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question