using System.Collections.Generic; using UnityEngine; public class WorldMapSpawnController : MonoBehaviour { [HideInInspector] public GameObject Player; [HideInInspector] public Transform DefaultSpawnLocation; [HideInInspector] public List SpawnLocations; [SerializeField] private GameObject _playerPrefab; [SerializeField] private Transform[] _spawnLocationsPrefabs; [SerializeField] private Transform _defaultSpawnLocationPrefab; private void OnEnable() { Player = Instantiate(_playerPrefab); DefaultSpawnLocation = Instantiate(_defaultSpawnLocationPrefab); foreach (var spawnLocationPrefab in _spawnLocationsPrefabs) SpawnLocations.Add(Instantiate(spawnLocationPrefab)); var cc = Player.GetComponent(); cc.enabled = false; Player.transform.position = DefaultSpawnLocation.position; Player.transform.rotation = DefaultSpawnLocation.rotation; cc.enabled = true; } }