x


Access a static var from different named scripts?

(this is for testing purposes, and hopes to be adapted to my real game later)


I want to make multiple buttons on the GUI, (lets just say 3 buttons), When you click on the first button, the number1 script is activated the rest are deactivated, when you click on 2, 2 is activated rest deactivated, and same for 3 (the 3 scripts contain static vars for a weapons minimum and maximum damage). now i know how to do that, but i need help with this, i want my characters Attack script to be able to figure out which script is activated, grab its static var, and place it in a variable inside of a function. I already have everything setup IF i put the variables inside the function directly, i just need help to make it grab them from the other scripts
more ▼

asked Mar 04 '10 at 12:28 AM

Adam Bruns gravatar image

Adam Bruns
274 24 27 38

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

1 answer: sort voted first

to use static variables you just need to use classname.staticvariablename = xxx but your questions is not as clear as it should be.

more ▼

answered Mar 04 '10 at 07:34 AM

Ashkan_gc gravatar image

Ashkan_gc
9.3k 33 56 120

ok i have script A script B and script C on an empty game object, if A is activated, B and C are deactivated. if B is activated A and C are deactivated. so on so forth. I want my other script, named Attack, to be able to find out which script is activated (A B or C) and grab its static var.

Mar 05 '10 at 02:36 AM Adam Bruns

Sounds like you're going to need to create a static boolean var on each script and set it to true or false when it's activated. Then your character can check to see which script is true.

Apr 01 '10 at 04:37 PM Joshua Falkner
(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
x850
x284
x110

asked: Mar 04 '10 at 12:28 AM

Seen: 1935 times

Last Updated: Mar 04 '10 at 01:29 PM