Spawn in relation to other actors

Sure thing.
First, you go to your gamemode blueprint (don’t forget it to set it up in your project settings too) and create an array of the same type of your car blueprint (for example Car_BP) like so:
image
To turn your variable into an array, click on the icon next to the variable type and choose the checkboard-like icon:
image

Now head to your car bp, click on add component and search for Arrow, position it next to your car where you want the character to spawn like this for example (the box is the car):


That arrow isn’t rendered in the game just so you know.

Now there is a handful of ways to communicate between blueprints but since we’re not running casts on every tick we should be fine. Do this to get a reference to your gamemode: (your gamemode’s name might be different)
image

Now it’s time to do this:

Within your car bp as always, add these nodes next the nodes we’ve created earlier like this:


You can achieve the same result by adding this to the function that spawns your cars:

At this point, we’ve set up every car that gets spawned in the world to be referenced in the gamemode’s array.
Now we head back to your gamemode blueprint and create a function that would help us to spawn a character next to every spawned car.

Idk how you check if all your cars are spawned but when they all do, simply call the function from your game mode like this:
image
And we’re done! I would suggest a good practice, if you intended to use a casted reference multiple times within a blueprint, it’s better to only cast once in your BeginPlay and save it as a variable like this:
image

I rushed through things a little but I’m here if you have more questions :slight_smile:

3 Likes