Fix World Camera
This commit is contained in:
@@ -1,41 +1,19 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerSpawnController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject _player;
|
||||
public GameObject Player;
|
||||
[SerializeField]
|
||||
private GameObject _playerPrefab;
|
||||
[SerializeField]
|
||||
private GameObject _spawnLocation;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
var otherSpawnControllers = FindObjectsOfType<PlayerSpawnController>().Except(new[] { this });
|
||||
if (otherSpawnControllers.Any())
|
||||
Destroy(this);
|
||||
else
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (GameObject.FindGameObjectWithTag("Player") != null)
|
||||
{
|
||||
_player = GameObject.FindGameObjectWithTag("Player");
|
||||
_player.transform.position = _spawnLocation.transform.position;
|
||||
_player.transform.rotation = _spawnLocation.transform.rotation;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_player = Instantiate(_playerPrefab);
|
||||
_player.transform.position = _spawnLocation.transform.position;
|
||||
_player.transform.rotation = _spawnLocation.transform.rotation;
|
||||
DontDestroyOnLoad(_player);
|
||||
}
|
||||
Player = Instantiate(_playerPrefab);
|
||||
Player.transform.position = _spawnLocation.transform.position;
|
||||
Player.transform.rotation = _spawnLocation.transform.rotation;
|
||||
DontDestroyOnLoad(Player);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user