32 lines
785 B
C#
32 lines
785 B
C#
using Photon.Pun;
|
|
using UnityEngine;
|
|
|
|
public class MultiplayerBoatSpawner : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private MultiplayerBoatEntity boat_prefab;
|
|
|
|
private MultiplayerBoatEntity spawnedBoat;
|
|
|
|
private void Update()
|
|
{
|
|
if (!MultiplayerManager.InRoomLocationStatic)
|
|
{
|
|
return;
|
|
}
|
|
if ((bool)Singleton<Boat>.Instance && (bool)Singleton<Boat>.Instance.currentPlayerCharacter)
|
|
{
|
|
if (!spawnedBoat)
|
|
{
|
|
spawnedBoat = PhotonNetwork.Instantiate(boat_prefab.name, Singleton<Boat>.Instance.transform.position, Singleton<Boat>.Instance.transform.rotation, 0).GetComponent<MultiplayerBoatEntity>();
|
|
spawnedBoat.Init(Singleton<Boat>.Instance);
|
|
}
|
|
}
|
|
else if ((bool)spawnedBoat)
|
|
{
|
|
PhotonNetwork.Destroy(spawnedBoat.gameObject);
|
|
spawnedBoat = null;
|
|
}
|
|
}
|
|
}
|