player can enter the door
This commit is contained in:
@@ -1,19 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class SpawnManager : MonoBehaviour
|
||||
{
|
||||
public static SpawnManager Instance { get; private set; }
|
||||
|
||||
public GameObject DefaultPlayer;
|
||||
|
||||
private Transform _defaultPoint;
|
||||
private Vector3 _spawnLocation;
|
||||
private bool setPoint;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
@@ -23,53 +13,6 @@ public class SpawnManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
Destroy(gameObject);
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SceneManager.sceneLoaded += SceneLoaded;
|
||||
|
||||
}
|
||||
|
||||
private void SetSpawn(Vector3 spawn)
|
||||
{
|
||||
_spawnLocation = spawn;
|
||||
setPoint = true;
|
||||
}
|
||||
|
||||
private void SceneLoaded(Scene arg0, LoadSceneMode arg1)
|
||||
{
|
||||
print(_spawnLocation);
|
||||
if(arg0.buildIndex > 1)
|
||||
{
|
||||
var temp = GameObject.Find("SpawnHere").transform;
|
||||
DefaultPlayer.transform.position = temp.position;
|
||||
//Instantiate(DefaultPlayer, temp.position, Quaternion.identity);
|
||||
}
|
||||
if(arg0.buildIndex == 1)
|
||||
{
|
||||
if (!setPoint)
|
||||
{
|
||||
print("no default location set");
|
||||
SpawnAtStart();
|
||||
}
|
||||
else
|
||||
SpawnAtSetLocation();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnAtSetLocation()
|
||||
{
|
||||
print("Spawn at set location");
|
||||
DefaultPlayer.transform.position = _spawnLocation;
|
||||
setPoint = false;
|
||||
}
|
||||
|
||||
private void SpawnAtStart()
|
||||
{
|
||||
_defaultPoint = GameObject.Find("DefaultPoint").transform;
|
||||
DefaultPlayer.transform.position = _defaultPoint.position;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user