- Home /
Need a little help in script
I need a little help. In my app is a 8x8 or bigger grid ( simple planes ). Lets say i want to planes change color/size/do other action when i click them. I want to activate not only 1 plane, nor 5. The center, + right,left,up,down plane. This is the 2-3th hour and i still can't imagine how to do this. Thank you!
There are few diffrent ways you can do this.
If you could tell a bit more about how are you placing the planes (is the grid generated at run-time or not), Then I can chose what way should fit best.
Answer by Nivius@School · Apr 15, 2013 at 03:03 PM
make an array to symbolize each block (this is c#)
//[0,0][0,1][0,2][0,3][0,4]
//[1,0][1,1][1,2][1,3][1,4]
//[2,0][2,1][2,2][2,3][2,4]
public int[,] BlockArray = new int[3,5];
if klick BlockArray[x,y]
saveX=x //i don't know how to do this step, but i bet its not that hard
saveY=y //i don't know how to do this step, but i bet its not that hard
BlockArray[saveX,saveY]//[1,1] if klicked [1,1]
does_stuff
BlockArray[saveX,saveY-1]//[1,0] if klicked [1,1]
does_stuff
BlockArray[saveX,saveY+1]//[1,2] if klicked [1,1]
does_stuff
BlockArray[saveX-1,saveY]//[0,1] if klicked [1,1]
does_stuff
BlockArray[saveX+1,saveY]//[2,1] if klicked [1,1]
does_stuff
should work huh? :) maybe not the prettiest
*PS this is not "CODE" per say, its just the concept on how it could be done...
*PPS my first Answerer, i'm not that pro but i might help someone!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
help with door script! 3 Answers
Unity Jet Wing Animations! Help! 1 Answer
DamageScript 1 Answer
Help Solve This 2 Answers