Add airship level
Fix default spawn issue TODO: Fix issue with spawning when loading from other scenes
This commit is contained in:
31
Assets/Scripts/GameManager/WorldMapSpawnController.cs
Normal file
31
Assets/Scripts/GameManager/WorldMapSpawnController.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WorldMapSpawnController : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public GameObject Player;
|
||||
[HideInInspector]
|
||||
public Transform DefaultSpawnLocation;
|
||||
[HideInInspector]
|
||||
public List<Transform> 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<CharacterController>();
|
||||
cc.enabled = false;
|
||||
Player.transform.position = DefaultSpawnLocation.position;
|
||||
Player.transform.rotation = DefaultSpawnLocation.rotation;
|
||||
cc.enabled = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user