Quantcast
Channel: Questions in topic: "attach"
Viewing all articles
Browse latest Browse all 168

unable to attach a script to a prefab

$
0
0
I have a prefab that I am using with a script attached to it. Here is the code: using UnityEngine; using System.Collections; public class bagDetect : MonoBehaviour { public GameObject okToShoot; public bool canScore = true; void Start () { okToShoot.GetComponent ().okToScore = true; } void Update () { canScore = true; } } the problem is i cannot seem to attach the reference to it. It will not let me drag and drop or assign the variable. This is the error i get when i run the game. Any ideas on what i am doing wrong????? UnassignedReferenceException: The variable okToShoot of bagDetect has not been assigned. You probably need to assign the okToShoot variable of the bagDetect script in the inspector. UnityEngine.GameObject.GetComponent[ID355] () bagDetect.Start () (at Assets/bagDetect.cs:8)

Viewing all articles
Browse latest Browse all 168

Trending Articles



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