Add airship level

Fix default spawn issue
TODO: Fix issue with spawning when loading from other scenes
This commit is contained in:
2022-08-30 01:48:01 -07:00
parent 82bf43452b
commit 7a891a45f1
22 changed files with 3856 additions and 316 deletions

View File

@@ -19,17 +19,12 @@ namespace Scampz.GameJam
}
public void LoadScene(string sceneName, Transform spawnPoint, LoadSceneMode loadSceneMode)
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
{
StartCoroutine(LoadSceneAsync(sceneName, spawnPoint, loadSceneMode));
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
}
public void LoadFromWorldMap(LoadSceneMode loadSceneMode)
{
SceneManager.LoadScene("WorldMap", loadSceneMode);
}
private IEnumerator LoadSceneAsync(string sceneName, Transform spawnPoint, LoadSceneMode loadSceneMode)
private IEnumerator LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)
{
yield return null;
var player = GameObject.FindGameObjectWithTag("Player");
@@ -51,8 +46,6 @@ namespace Scampz.GameJam
yield return loadSceneOperation;
var cc = player.GetComponent<CharacterController>();
cc.enabled = false;
player.transform.position = spawnPoint.position;
player.transform.rotation = spawnPoint.rotation;
yield return null;
}
}

View File

@@ -1,6 +1,6 @@
using UnityEngine;
public class PlayerSpawnController : MonoBehaviour
public partial class PlayerSpawnController : MonoBehaviour
{
public GameObject Player;
[SerializeField]
@@ -14,5 +14,4 @@ public class PlayerSpawnController : MonoBehaviour
Player.transform.position = _spawnLocation.transform.position;
Player.transform.rotation = _spawnLocation.transform.rotation;
}
}

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

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ab97fce054425504e9f8c78312d1081d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: