Files
Scampz/Assets/Scripts/GameManager/PlayerSpawnController.cs
2022-08-16 01:49:55 -07:00

28 lines
631 B
C#

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