- Home /
Question by
mmcelt · Jun 27, 2017 at 01:52 PM ·
spawning problems
Spawning routine works in 5.5.2f1 But doesn't work in 5.6.2f1
This code is called from my GameManager at the beginning of the game. It spawns two "Stickers" on my game board for each player. It works fine in version 5.5.2f1, but will only spawn the first sticker for each player using 5.6.2f1.
[Command]
public void CmdSpawnInitialBoardStickers()
{
if (_pSetup == null)
{
_pSetup = GetComponent<PlayerSetup>();
}
GameObject hayStickerPrefab = _boardStickerPrefabs[13];
GameObject grainStickerPrefab = _boardStickerPrefabs[7];
Vector3 haySpawnLocation = Vector3.zero;
Vector3 grainSpawnLocation = Vector3.zero;
switch (_pSetup._farmerName)
{
case "Ririe Ric":
haySpawnLocation = new Vector2(-1.4f, 0.5f);
grainSpawnLocation = new Vector2(-1.05f, 0.5f);
break;
case "Rigby Ron":
haySpawnLocation = new Vector2(4.5f, -1.9f);
grainSpawnLocation = new Vector2(4.85f, -1.9f);
break;
case "Jerome Jerry":
haySpawnLocation = new Vector2(-0.6f, -1.2f);
grainSpawnLocation = new Vector2(-0.25f, -1.2f);
break;
case "Menan Mike":
haySpawnLocation = new Vector2(5.64f, 1.06f);
grainSpawnLocation = new Vector2(5.99f, 1.06f);
break;
case "Bone Becky":
haySpawnLocation = new Vector2(3.14f, 1.49f);
grainSpawnLocation = new Vector2(3.49f, 1.49f);
break;
case "Kimberly Kay":
haySpawnLocation = new Vector2(2.2f, 0.1f);
grainSpawnLocation = new Vector2(2.55f, 0.1f);
break;
}
GameObject haySticker = Instantiate(hayStickerPrefab, haySpawnLocation, Quaternion.identity);
NetworkServer.Spawn(haySticker);
GameObject grainSticker = Instantiate(grainStickerPrefab, grainSpawnLocation, Quaternion.identity);
NetworkServer.Spawn(grainSticker);
}
Comment
This is the calling code in the Game$$anonymous$$anager:
private void SpawnThePlayerInitialBoardStickers()
{
if (!isServer)
{
return;
}
foreach (Player$$anonymous$$anager player in _allPlayers)
{
Spawn$$anonymous$$anager s$$anonymous$$anager = player.GetComponent<Spawn$$anonymous$$anager>();
s$$anonymous$$anager.CmdSpawnInitialBoardStickers();
}
}