How to spawn an actor just in front of the player at a set distance?

How to spawn an actor just in front of the player at a set distance?

In a BP, do a getactorlocation of the player you want to spawn in front of. That should be a vector. Connect a Vector + and add whatever offset you want. Plug that vector into a spawn actor. It probably will require a transform. For that, just plug the vector into location in a MakeTransform.

Another option would be to place a component (sphere, cube arrow, whatever) on your character blueprint where you’d want the object to spawn. (be sure to set the rendering of said component to unseen by player). Name your new component “SpawnPoint” or whatever you want and position it in the viewport where you want your stuff to spawn. Then, when you’re ready to spawn your pick-up or whatever cast to your player character, use GetWorldLocation of you “SpawnPoint” and SpawnActor of Class with the item pick up as the class.

Something like this:

thats not true.
what you need is “get forward vector” of the actor. multiply it by a float (which is the distance) and add it to the actor location. THIS is now the point in front of you in given distance. plug it into the “spawn actor from class” transform

8 Likes

Answer from MajekPL is correct, this is how it’s done in bp’s:

17 Likes

OMG, thank you for actually SHOWING the procedure.

1 Like

Hello, even the solution from the first screenshot (2016) is very helpful for me.

But the 2nd one (from 2021) is what I was searching for.

I have a box, and when I shot it, then it spawns an item. In the 2nd screenshot the “ref to self” is connected to “instigator”. But I am not allowed to connect it. I am in my “crate_BP” and build it exactly like in the picture. I am using UE5.2

How to solve the problem? (hope my Engl is good enough without translator)

you don’t need to connect the instigator

OK