I want to be able to pull a variable from one script to another one, i’m not sure how…
void Update(){ if (Input.GetMouseButtonDown (0)) { if (count <= 0) { NoAmmo.Play (); } if (count > 0) { Gun.Play (); count = count - 1; SetCountText (); } } }
i want to be able to get the count component, as it decides if an object will be removed or not
At the top of the script, define a: public int (or float) count;
Then, in a different script you need to get access to this script (I don’t know the name of your class): private GunScript gunScript = otherGameobject.getComponent(); Debug.Log(gunScript.count);