Fix PlayerSpawnController bug that sometimes caused player to spawn in wrong location
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerSpawnController : MonoBehaviour
|
||||
@@ -9,7 +10,17 @@ public class PlayerSpawnController : MonoBehaviour
|
||||
[SerializeField]
|
||||
private GameObject _spawnLocation;
|
||||
|
||||
void Awake()
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
var otherSpawnControllers = FindObjectsOfType<PlayerSpawnController>().Except(new[] { this });
|
||||
if (otherSpawnControllers.Any())
|
||||
Destroy(this);
|
||||
else
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (GameObject.FindGameObjectWithTag("Player") != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user