Spawning actor behind player position

Hello everyone

I started to learn Blueprint system and find it really great.
What i am trying to do now is to place a class (actor) behind player “movement” or at his back.
I’ve already created BluePrint class with sphere object and i can trigger event when “space” is being pressed.
Also i got vector of movement of the player , though i have 2 problems i am not sure how to resolve.
First i need to place object “behind” player , at his back when he is moving. So i assume this should be like this :

determine vector of movement (x as example)

spawn position = position of player (x - 5 , y , z)

This is simple algorithm though i am not sure how to interpreter it in Blueprint language.
The second thing is to detect last vector of movement (when player just stands still) , and class is spawned behind him.

#Spawn Blueprint

Create a blueprint for the class that you want to spawn, or use an existing one,

and then use the Spawn blueprint node!

if you cant find it, turn context sensitive off

:slight_smile:

#Get Forward Vector

Get the player character unit

Get the player’s Forward Vector

Multiply by a NEGATIVE number

Character's Forward Vector * -256

that will be behind the facing direction of the player character

#:heart:

Rama

Thanks for your answer,

How should i spawn a class at that position ((Character’s Forward Vector * -256) , Y , Z) I know that there is spawn node , i mean what is the scheme to show that it should spawn at that position exaactly ? Is there a node to join several vectors in lication vector ? I am unsure about this part…
Sorry i am really a newbie with this but i learn fast :slight_smile:

Nor as simple as you think :slight_smile:

This is a very hairy question because one can’t just compute what Rama proposed (spawnPosition = -ForwardVector * offset). That would end up with spawning in a wall, into a prop and so on… any actor relative automatic spawning system must be environment-aware, and that is not an easy task.

The easiest way to do so is to sphere-cast on the computed spawnPosition from above to determine the ground level at that given point. Here you alse have to make sure that you indeed hit the ground and not something else, so you can use layering or tagging to define and isolate where you can actually spawn your pawn on.

Once you have a clear surface you also need to make sure to have enough space, so I would spawn a collision volume having the very same bounds of the pawn you want to spawn. This has to be there for just 1 frame to detect any overlap and tell you back that an overlap occurred, so that you can look for another spot where to spawn the actor.

Rama is correct, however I would also look at DFT’s suggestions below as those are also very relevant!

Great work community, keep it up!

-W

Yes that’s actually the answer , thanks for your help guys , and thanks DFT for your hints !