mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-25 15:08:00 +01:00
33 lines
986 B
C#
33 lines
986 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class OnJoinedInstantiate : MonoBehaviour
|
|
{
|
|
public Transform SpawnPosition;
|
|
public float PositionOffset = 2.0f;
|
|
public GameObject[] PrefabsToInstantiate; // set in inspector
|
|
|
|
public void OnJoinedRoom()
|
|
{
|
|
if (this.PrefabsToInstantiate != null)
|
|
{
|
|
foreach (GameObject o in this.PrefabsToInstantiate)
|
|
{
|
|
Debug.Log("Instantiating: " + o.name);
|
|
|
|
Vector3 spawnPos = Vector3.up;
|
|
if (this.SpawnPosition != null)
|
|
{
|
|
spawnPos = this.SpawnPosition.position;
|
|
}
|
|
|
|
Vector3 random = Random.insideUnitSphere;
|
|
random.y = 0;
|
|
random = random.normalized;
|
|
Vector3 itempos = spawnPos + this.PositionOffset * random;
|
|
|
|
PhotonNetwork.Instantiate(o.name, itempos, Quaternion.identity, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|