Multiplayer System to spawn players at semi-random location?

Hi,

I am experimenting with a multiplayer RTS project and I would like to get some advice for the best approach.

I want to make a spawning system that places each player at one of a pre-defined random locations when the level starts. I don’t want to use the Level Blueprints, because I have several levels/maps and I have a suspicion that this can be done in a more efficient way than creating it for each level. I am using Target Points as my possible spawn locations, and I’ve already set them up for each of my levels/maps.

The answer is probably pretty obvious, but my main problem is that I can’t think of a way to trigger this spawning system when a level loads up. My initial idea was to create the system in the Game Mode, but as I couldn’t find a way to check if my level is loaded, I have no idea what should trigger it.

I am a bit confused about this, and would appreciate some help.

I hope I can answer my own question.

Is that a possible solution that I set up the system in the Game Mode and I just call it from each Level Blueprint at Event Begin Play?

You could use “Get All Actors Of Class” which will output an array. In this case you would look for all of the Target Points. Then you could randomly select a point for Team 1 for the array, remove that Target Point from the array, and then randomly select another one for Team 2.

Of course, you could do other stuff like make sure the points are far enough away from each other as well.

Well, you could just store the entire “spawn point algorithm” in a scene component (or any custom blueprint) that gets spawned as part of the levels begin play event. You really only have to setup this one step for each level since your spawn logic lives inside that blueprint.

Just make sure all the variables you access external to the “spawn point” blueprint lines up properly (or is determined/generated programatically) to avoid null reference errors.