- Home /
variable = true from another script
hey, how do i activate a function using a true/false variable from another script?
var Shoot : ArrowControl = gameObject.Find("Arrow").GetComponent(ArrowControl);
if(Shoot.fire == true)
{
Debug.Log("2");
Fire();
}
Answer by Justin Warner · Dec 27, 2010 at 04:07 AM
Get the object the script is on.
From that object, get the component on it.
On the component (Probably the script), set it equal to false/true. You have it right, just you aren't actually getting it from the target gameobject, I had this problem as well before.
I think I should add. What I said above, about getting it from the actual gameobject. That's all you need to do. Sorry to reiterate, I just think it's best if you get that from my answer.
Answer by TurboHermit · Mar 08, 2012 at 12:16 AM
I believe you can't declare the object and components in the variable it self... That needs to be done in an update or other function
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Static function and variables error 2 Answers
Error on my javascript code 1 Answer
Changing variables in GUI? 0 Answers