Quantcast
Viewing latest article 13
Browse Latest Browse All 34

How to create a variable in another object

In my game, I am creating many GameObjects in a 3 dimensional array like this: internal var chunks : GameObject[,,]; Now I want to put a variable into each game object. For example: chunks[1,0,3].newvariable : int = 4; In this case, I want to create a variable called "newvariable" into that particular gameobject. I also want to be able to access the variable later, like this: print(chunks[1,0,3].newvariable); This code doesn't work, so Im asking for your help to do this correctly. Can anyone help me accomplish this?

Viewing latest article 13
Browse Latest Browse All 34

Trending Articles