mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Simplified Spawner (#1244)
This commit is contained in:
parent
d0c0f394f7
commit
4c0fb9ba34
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user