It Instantiates the player at the start of the game. However, when the next scene is loaded it doesn’t re-Instantiate the player. Am I over-looking something? It was working before.
public class GameMaster : MonoBehaviour{
public Camera mainCamera;
private GameObject playerCharacter;
private GameObject headsUpDisplay;
private GameObject eventSystem;
private GameObject pc;
private GameObject cam;
private PlayerCharacter pcScript;
private Vector3 playerSpawnPointPos;
void Awake(){
DontDestroyOnLoad(this);
}
void Start () {
playerSpawnPointPos = ChooseSpawnPoint.PickSpawnPoint(Application.loadedLevelName.ToString(), PlayerPrefs.GetString("Last Zone", "PalletTownIntro"));
playerCharacter = (GameObject)Resources.Load("Prefabs/Player Character Prefab");
pc = Instantiate(playerCharacter, playerSpawnPointPos, Quaternion.identity) as GameObject;
Debug.Log(Application.loadedLevelName);
if(Application.loadedLevelName == "MainMenu" || Application.loadedLevelName == "CharacterGeneration"){
pc.GetComponent<Movement>().enabled = false;
pc.GetComponent<PokeBallThrow>().enabled = false;
pc.GetComponent<PokemonEncounter>().enabled = false;
}
pc.name = "Player Character";
pcScript = pc.GetComponent<PlayerCharacter>();
cam = Instantiate(mainCamera, Vector3.zero, Quaternion.identity) as GameObject;
if(Application.loadedLevelName != "MainMenu" || Application.loadedLevelName != "CharacterGeneration"){
LoadCharacterData();
headsUpDisplay = (GameObject)Resources.Load("Prefabs/HUD Prefab");
eventSystem = (GameObject)Resources.Load("Prefabs/Event System Prefab");
Instantiate(headsUpDisplay, Vector3.zero, Quaternion.identity);
Instantiate(eventSystem, Vector3.zero, Quaternion.identity);
}
pcScript.LastZone = Application.loadedLevelName.ToString();
SaveCharacterData();
}