I’m making a spaceship game where players spawn at a spawn point on each side. The script below, which fires once per player when they enter the scene, puts the player on a team and spawns them at the one spawn point for that team. However, if multiple players spawn at once, it becomes chaos (no one wants that). I want players to spawn only when there is no fighter already there; in other words, wait to spawn until the spawn point is clear. The “Spawn Collision Check” script mentioned uses a trigger to see if anything is inside the spawn point. Here’s the code I have so far:
var redPrefab : Transform;
var bluePrefab : Transform;
var redSpawn : Transform;
var blueSpawn : Transform;
function OnNetworkLoadedLevel (playerNum : int)
{
if (playerNum % 1 == 1){
if (blueSpawn.GetComponent("SpawnCollisionCheck").spawnHit == true){
yield;
}
else{
Spawn(1);
}
}
else{
if (redSpawn.GetComponent("SpawnCollisionCheck").spawnHit == true){
yield;
}
else{
Spawn(0);
}
}
}
I’m guessing the solution has to do with coroutines, but this script is fired once per player. How do I spawn each character in sequence?