- Home /
Iterate through area descibed by objects
Hi, I write a 2d grid-based game with grid 1x1 - when I move stay after player objects (all objects are 1x1), how can i iterate closed area described by objects? Many thanks for help.
It's look that: and I want to Instantiate objects where i marked black pencil... how can i do this?
Answer by Akusan · Sep 06, 2017 at 08:14 PM
Just create an array taking an integer variable which signifies a condition for each grid square, for example:
player cannot walk on to
player can walk but not walked yet
player can walk and walked on it
And you can make more conditions than that. Then based on the condition, change the color of the tile using instantiate and destroy old objects if you have to. If you have an array then you can easily iterate using a for each loop.
Yeah, thats greate idea - after that i can do loop in loop for fill inside blocks ;) - thanks for good direction ;)
No problem. I'm glad I could help. Good luck on your game.
Your answer
Follow this Question
Related Questions
Need help writing script 1 Answer
Auto-move on grid and draw line problem 0 Answers
How do I make it so it spawns 1 clone instead of 2? 2 Answers
Limit player speed (2D) 3 Answers