How would i go about switching back and forth between scenes and using the DontDestroyOnLoad function without creating a duplicate player gameobject.
This will stop duplicates.
using UnityEngine;
using System.Collections;
public class DontDestroyScript : MonoBehaviour {
public static bool created = false;
void Awake() {
if (!created) {
DontDestroyOnLoad(this.gameObject);
created = true;
}
else {
Destroy(this.gameObject);
}
}
}