Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

how to solve -- Object reference not set to an instance of an object -- ?

$
0
0
At the end of my level there is a sign that when you touch it will bring you to the world map. In this script that is attached to the sign i activate a bool "LVL1_1_Completed " **Script on sign** using UnityEngine; using System.Collections; public class WinLVL1_1 : MonoBehaviour { public bool LVL1_1_Completed; void Start () { } void Update () { } void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { PlayerHealth PlayerWins = other.gameObject.GetComponent (); PlayerWins.WinGame (); LVL1_1_Completed = true; } } } On the canvas of the world map i have a script that must check if the bool is true .... if it is true the next level must be unlocked. **Script on world map** using UnityEngine; using System.Collections; public class UnlockLevels : MonoBehaviour { public GameObject UnlockLVL_1_2; void Start () { } void Update () { if (GameObject.Find("SignLVL_1_1").GetComponent().LVL1_1_Completed) { UnlockLVL_1_2.SetActive (true); } } } When i hit play it gives me an error that says "Object reference not set to an instance of an object" in the line "if (GameObject.Find("SignLVL_1_1").GetComponent().LVL1_1_Completed)". Please help me with this ;p

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>