How to spawn objects relative to a player


I am trying to spawn 2 objects relative to a player. One should be spawned 100 units/pixels to the right and the other 100 units/pixels to the left. Both of them 500 units in front of the player. I always need them to spawn in front, left and right of the player. I tried getting the player’s location and just adding the offsets, but it’s not always in front( based on the player’s rotation, adding 100 pixels to x could mean front or back)

I am using unreal engine 4.19, and i need this done with blueprints!

Hope someone can help me, thanks in advance!

The units will mostly be centimeters becasue it’s the UE4 base unit. Can you show a screenshot of your script? You have mostly to get first the player front vector which is the direction the player is facing and then use that to derive the location you want.

To get a facing direction, you will need GetActorForwardVector() - Which will give the vector down the X axis (Usually the way the actor is facing). Then 100 units infront of the player will be the PlayerLocation + (ForwardVector * 100). The same for the right, but use the RightVector instead.

@Dune @graphicsgriffin I managed to do it eventually. Thanks for the help guys!

Glad you managed to do it. Keep it up!