x


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();
}
more ▼

asked Dec 27 '10 at 03:44 AM

Jason Hamilton gravatar image

Jason Hamilton
445 68 73 80

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first
  1. Get the object the script is on.

  2. From that object, get the component on it.

  3. 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.

more ▼

answered Dec 27 '10 at 04:07 AM

Justin Warner gravatar image

Justin Warner
6.3k 19 27 65

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.

Dec 27 '10 at 04:53 AM Justin Warner
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Mar 08 '12 at 12:16 AM

Danzou gravatar image

Danzou
220 16 29 40

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5273
x3570
x850
x498
x284

asked: Dec 27 '10 at 03:44 AM

Seen: 1545 times

Last Updated: Mar 08 '12 at 12:16 AM