Simplified Spawner (#1244)

This commit is contained in:
MrGadget 2019-11-28 11:35:23 -05:00 committed by Paul Pacheco
parent d0c0f394f7
commit 4c0fb9ba34

View File

@ -6,12 +6,6 @@ public class Spawner : NetworkBehaviour
{ {
public NetworkIdentity prizePrefab; public NetworkIdentity prizePrefab;
float x;
float z;
GameObject newPrize;
Reward reward;
public override void OnStartServer() public override void OnStartServer()
{ {
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
@ -20,12 +14,11 @@ public override void OnStartServer()
public void SpawnPrize() public void SpawnPrize()
{ {
x = Random.Range(-19, 20); Vector3 spawnPosition = new Vector3(Random.Range(-19, 20), 1, Random.Range(-19, 20));
z = 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; newPrize.name = prizePrefab.name;
reward = newPrize.gameObject.GetComponent<Reward>(); Reward reward = newPrize.gameObject.GetComponent<Reward>();
reward.spawner = this; reward.spawner = this;
NetworkServer.Spawn(newPrize); NetworkServer.Spawn(newPrize);