x


Accessing variables and arrays from inside classes?

If you have a class created at the start of the script, is there anyway to get variables or arrays from outside that class, say if you have a class function you want to create?

Something like:

var start : vector3 = (0,1,0);



class Player {

   function Move (){

     player.transform.position = start; 

     etc

   }

}

Is it possible to do anything like this? Thanks for your time.

more ▼

asked Nov 07 '10 at 10:02 PM

Soulis6 gravatar image

Soulis6
19 1 1 4

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

1 answer: sort voted first

It is possible using static variables. Static variables have global scope (can be accessed anywhere).

more ▼

answered Nov 07 '10 at 11:57 PM

_Petroz gravatar image

_Petroz
3.6k 27 35 57

Great, thanks. That worked. Is there a way to do something like that for arrays as well? I couldn't find anything in the documentation about that.

Nov 08 '10 at 12:32 AM Soulis6

Any data type can be static, that includes arrays.

Nov 08 '10 at 09:11 AM _Petroz
(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:

x1363
x826
x339

asked: Nov 07 '10 at 10:02 PM

Seen: 832 times

Last Updated: Nov 07 '10 at 10:02 PM