when i re-load the level that this originates on it creates a duplicate and im not sure how to stop it from doing that. any ideas? and checking for this on load to delete it it only deletes it when i start to test.
using UnityEngine;
using System.Collections;
public class Variables : MonoBehaviour {
private static GameObject Player;
public static int num = 0;
public static int RN;
public static bool randEncounter = true;
public static bool inBattle = false;
public static int BattleRangeMin = 1;
public static int BattleRangeMax = 20;
public static int Exp = 0;
public static Vector3 playerPosition;
public static Vector3 positionAfterBattle;
public int loop = 0;
public static bool Win = false;
//public static
void Awake(){
DontDestroyOnLoad(this.gameObject);
}
// Use this for initialization
void Start () {
randEncounter = true;
inBattle = false;
}
// Update is called once per frame
void Update () {
///Debug.Log();
//playerPosition = GameObject.Find("First Person Controller").transform.position;
///playerPosition = Player.transform.position;
if(inBattle){
if (loop <= 0){
playerPosition = GameObject.Find("First Person Controller").transform.position;
//positionAfterBattle = playerPosition;
loop = loop + 1;
if(loop == 1){
}
}
}
if(Win){
Application.LoadLevel("script testing");
Player = GameObject.Find("First Person Controller");
transform.position = positionAfterBattle;
RandomEncounterScript.myState = RandomEncounterScript.battleStates.FreeRoam;
inBattle = false;
randEncounter = true;
Win = false;
}
}
}