Alright here is the problem, I am trying to get the moved boolean in one script so I can use it in another script. I’ve declared it public var moved : boolean = false; and it even shows up with the little check box in the inspector. But then I try to access it from a script attached to a different game object, like this:
Physics.Raycast(transform.position, Vector3.right, hit, 3.0);
if(hit.collider.gameObject.tag.Contains("tile")){
var tile = GameObject.FindGameObjectWithTag(hit.collider.gameObject.tag);
Debug.Log(tile.moved);
I get “Assets/Script/Shuffle.js(29,48): BCE0019: ‘moved’ is not a member of ‘UnityEngine.GameObject’.”
and I’ve tried Debug.Log(tile.GetComponent("Slider").moved); Slider.js being the name of the first script.
You need to use GetComponent with the GameObject that’s returned by FindGameObjectWithTag. The variable is part of the script component, not the GameObject.
Thank you everyone for you suggestions. Unfortunately, as it usually is, the problem was just a stupid mistake. I had tile.GetComponent("Slider").moved when the quotes were unnecessary its just tile.GetComponent(Slider).moved