- Home /
Clients moves to NetworkSpawnPositions at start
Hi!
Why does the clients gameobjects moves from [0,0,0] to the NetworkSpawnPosition instead of spawning at that position? Now our Clients gets stuck in walls and each other because of this insane behavior on their way to the NetworkSpawnPosition. Does anyone have any idea to stop this behavior and just have the GameObject pop up at the spawn position when a GameObject is instaniated?
We have overriden the OnLobbyServerCreateGamePlayer function and does this:
public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControlID)
{
Debug.Log("OnLobbyServerCreateGamePlayer");
if(availableSpawnPoints.Count == 0)
{
for(int i = 0; i < startPositions.Count; i++)
{
availableSpawnPoints.Add(startPositions[i].position);
}
}
int randomSpawn = Random.Range(0, availableSpawnPoints.Count - 1);
int randomPlayer = Random.Range(0, availablePlayers.Count - 1);
GameObject playerPrefab = (GameObject)Instantiate(availablePlayers[randomPlayer], availableSpawnPoints[randomSpawn], Quaternion.identity);
availableSpawnPoints.RemoveAt(randomSpawn);
availablePlayers.RemoveAt(randomPlayer);
return playerPrefab;
}
This only happens on the Clients and not on Hosts GameObject.
Please help and have been stuck on this for hours now :( Let me know if you need any more information/code from me.
Best Regards Kalle
Your answer
Follow this Question
Related Questions
No appropriate version of 'UnityEngine.Object.Instantiate' 0 Answers
How to spawn gameobject from host to all clients 1 Answer
UNet - How do I make Network.Spawn not show the prefab to the user that called it? 1 Answer
How to to spawn player, according to id? 0 Answers
Problems with spawning items that the players can pick up - Unet 0 Answers