Fix World Camera

This commit is contained in:
2022-08-20 15:38:13 -07:00
parent 15a7e16650
commit 349c4dc4b6
26 changed files with 4085 additions and 2158 deletions

View File

@@ -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);
}
}