I’m trying to sequentially select player spawn positions in order as each player joins the server. The host takes the first position, and then each player that joins will take the next position in the order of the elements in the array. I initialize the array in the Construction Script for the GameMode used in my level -
But overriding ChoosePlayerStart
in the GameMode blueprint using the setup below does not work for selecting player spawn position sequentially instead of randomly. I have 2 players on the level. The array is of length 2, the first iteration selects index 0, the second selects index 1. The default value of PlayersSpawned is 0.
The first player spawn works correctly
For some reason fetching the array index 1 returns an Unknown object, resulting in character spawn failing. In this screenshot PlayersSpawned is 2 but we called Get (a copy) prior to incrementing, so the value was 1 when this was called.
I added checks to IsValid after Get (a copy) to see if the result is invalid - the check passes and claims it is valid. I added a precheck at the beginning of the function seen in the first screenshot that validates the index is valid and that check passes as well.
Still the player does not spawn?
But if I do this instead with a static value of 0 or 1, both players spawn correctly (both players spawn on the same position, depending on which static value was used). Do I need a coffee break or is something weird going on here?
Here is a guide that i referenced when setting this up, thank you in advance