How to get access to bool from one script to another with touch input?
Button script quiet basic:
public bool wepFired = false;
void OnTouchDown()
{
mat.color = selectedColour;
wepFired = true;
}
Player script which handle if the button being pressed:
FireButton wepScript = GetComponent<FireButton>();
gameObject.GetComponent<FireButton>().wepFired;
if(wepFired == true)
{
wepFiredwithButton = true;
}
else
{
wepFiredwithButton = false;
}
if ( wepFiredwithButton == true)
{
Debug.Log ("AmmoSpawn");
If any can help with this problem I would much appreciate it! Thank you Dan
Comment
Answer by MechanicalGaming · Dec 09, 2015 at 12:39 AM
Change the public bool to a public static bool. then in the player script use 'scriptName'.wepFiredWithButton replace the 'scriptName' with the name of the script... Obviously.
Your answer
Follow this Question
Related Questions
Hold touch button Unity Javascript 1 Answer
Touch on 2D gameobject: should i use a GUI button? 1 Answer
UI button events not working on android 3 Answers
buttons vs touch. 1 Answer