lost me mind i did
This commit is contained in:
28
Assets/Scripts/GameManager/PlayerSpawnController.cs
Normal file
28
Assets/Scripts/GameManager/PlayerSpawnController.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerSpawnController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject _player;
|
||||
[SerializeField]
|
||||
private GameObject _playerPrefab;
|
||||
[SerializeField]
|
||||
private GameObject _spawnLocation;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (GameObject.FindGameObjectWithTag("Player") != null)
|
||||
{
|
||||
_player = GameObject.FindGameObjectWithTag("Player");
|
||||
_player.transform.position = _spawnLocation.transform.position;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_player = Instantiate(_playerPrefab);
|
||||
_player.transform.position = _spawnLocation.transform.position;
|
||||
DontDestroyOnLoad(_player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user