- Home /
How to access variables from an object based on location? C# (Pic inside)
My basic issue is this, I have multiple game objects set up in a 3x3 grid. Each game object holds a number value. I want a game object to recognize the NUMBER VALUE from each other game object that shares a common border.
This picture should explain more clearly:
In this image each square would be the game object I spoke of and each number inside the square would be the number value assigned. So I want the top left square with the value of 1 to recognize that it is touching borders with the top right and bottom left squares and also distinguishing that top right = 2 and bot left = 3. There should be no recognition of bottom right or the value 4.
The numbers value are not hard coded to the game objects, they will be changing variables depending on the level.
Any tips or help would be greatly appreciated.
Answer by ham3d · Oct 08, 2014 at 10:03 AM
You should simply create a 2x2 array and put these game objects in it. By a index you can access to any number you want.
for example number 3 is A[1][0] and number 2 is A[0][1] and so on ...
Your answer
Follow this Question
Related Questions
C# Check If Scripted Gameobject goes Past Variable Gameobject 0 Answers
Using script's method from all of the gameobjects that has that script 2 Answers
c# destroy gameobject on 0 hp 2 Answers
2D C# destroy a GameObject on collision 2 Answers
why not run animation when doublication gameObject ???? 0 Answers