From 4c0fb9ba346db537a06158cfa15c0a538ffd6371 Mon Sep 17 00:00:00 2001 From: MrGadget Date: Thu, 28 Nov 2019 11:35:23 -0500 Subject: [PATCH] Simplified Spawner (#1244) --- Assets/Mirror/Examples/Room/Scripts/Spawner.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Assets/Mirror/Examples/Room/Scripts/Spawner.cs b/Assets/Mirror/Examples/Room/Scripts/Spawner.cs index aea01d7c6..90647c7dd 100644 --- a/Assets/Mirror/Examples/Room/Scripts/Spawner.cs +++ b/Assets/Mirror/Examples/Room/Scripts/Spawner.cs @@ -6,12 +6,6 @@ public class Spawner : NetworkBehaviour { public NetworkIdentity prizePrefab; - float x; - float z; - - GameObject newPrize; - Reward reward; - public override void OnStartServer() { for (int i = 0; i < 10; i++) @@ -20,12 +14,11 @@ public override void OnStartServer() public void SpawnPrize() { - x = Random.Range(-19, 20); - z = Random.Range(-19, 20); + Vector3 spawnPosition = new Vector3(Random.Range(-19, 20), 1, Random.Range(-19, 20)); - newPrize = Instantiate(prizePrefab.gameObject, new Vector3(x, 1, z), Quaternion.identity); + GameObject newPrize = Instantiate(prizePrefab.gameObject, spawnPosition, Quaternion.identity); newPrize.name = prizePrefab.name; - reward = newPrize.gameObject.GetComponent(); + Reward reward = newPrize.gameObject.GetComponent(); reward.spawner = this; NetworkServer.Spawn(newPrize);