Hello. I have a very simple question. I have a game with 2 maps. On the 2 maps you can destroy objects with a gun … but when I change the map I want to have again 0 Kills on the Point Counter. Now if I change the level the kills remain saved. How can I make that if I change level Point Count = 0 ?
Here are my scripts:
using UnityEngine; using System.Collections; public class PointCounter : MonoBehaviour { public GUISkin guiSkin = null; public static int points = 0; void OnGUI() { GUI.skin = guiSkin; GUI.Label(new Rect(317.0f, 78.5f, 400.0f, 120.0f), points.ToString()); GUI.skin = null; } void Awake() { DontDestroyOnLoad(transform.gameObject); } }
and the 2nd script is:
using UnityEngine; using
System.Collections;public class Zombie : MonoBehaviour {
public int points = 1; // You can edit this in the inspector void OnDestroy() { PointCounter.points += points; } void OnDontDestroy() { PointCounter.points -= points; } void Awake() { DontDestroyOnLoad(transform.gameObject); } }
I NEED VERY FAST HELP! Thank you in advance for every answer ![]()