I have an AI game object (that is technically the host’s game object) that I want to spawn exactly at the position where a Network Start Position is located. When spawning the AI game object, I want to spawn them via Round Robin style.
I would like to know how to “manually” spawn a game object exactly on the Network Start Position. How would I do this?
I know that the Network Start Position is used for spawning player game object prefabs via NetworkServer’s Spawn Info. Maybe I could use NetworkServer.Spawn() to spawn the game object that I wanted to have on the Network Start Position, but I don’t know how I need to achieve this.
I welcome all ideas. Thanks.
EDIT:
I also know that you can use
GameObject[] startPositions = GameObject.FindObjectsWithTag("StartLocation"); //"StartLocation" is the NetworkStartPosition game object's custom tag name that is set in the editor. It's just an example.
To find all the Network Start Positions, but how would you tell there’s an object already at this location? Or that all but 1 Network Start Positions are registered so the other players’ units are spawned from their respective locations? (The remaining Network Start Position is only available to the AI player when all players are randomly assigned to a Network Start Position, even when using Round Robin mode.)
EDIT 2:
Can you obtain NetworkStartPositions from the NetworkManager? Or from a subclass of NetworkManager?
EDIT 3:
I think I got it. Use
NetworkManager.GetStartPosition();
to obtain a Transform from an available NetworkStartPosition, and just set the game object’s position to that obtained Transform’s position.