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

Why doesn't enabling and disabling not work?

$
0
0
I am a noob a programer but I can't find how to find a solution to this error: NullReferenceException: Object reference not set to an instance of an object CTF.Changing_Color.ChangingFlagColor () (at Assets/Scripts/Changing_Color.cs:29) CTF.Changing_Color.Start () (at Assets/Scripts/Changing_Color.cs:16) My Code: using UnityEngine; using System.Collections; namespace CTF { public class Changing_Color : MonoBehaviour { private RaycastHit hit; public GameObject Red; public GameObject Blue; public GameObject Neutral; // Use this for initialization void Start() { } // Update is called once per frame void Update() { ChangingFlagColor(); } void ChangingFlagColor() { if(hit.transform.CompareTag("Blue")) { Red.SetActive(false); Blue.SetActive(true); Neutral.SetActive(false); } if (hit.transform.CompareTag("Red")) { Red.SetActive(true); Blue.SetActive(false); Neutral.SetActive(false); } } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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