- Home /
Design discussion
How can I find an adjacent tile, if the tiles vary in shape and size?
Working on a risk-style game, need to be able to find which tiles a unit can move to, depending on which tile it is on, keeping mind that the tiles are countries/territories. Any ideas? Each territory is an individual 3d game object.
General discussion questions like this one, especially with such sparse information about the problem, are not a good fit for Unity Answers. Unity Forums has a much better format for this kind of discussion. Even there, this question has little to do with Unity, and is mostly a data structure question. If you ask at the Forums, I suggest you include more details...number of countries, range on the number of adjacent countries, factors effecting player movement...
Answer by RPGstandard · Jul 28, 2013 at 07:25 AM
You could do this by implementing a location state within your territories. For example, if you have Units sitting in the United States territory and you want them to move to either Canada or Mexico, you can assign the units a value based on their current location and using some type of number system (possibly Octal, based on the territory with the highest number of bordering territories) you can determine what areas your units are capable of moving to.
So essentially set up a function that gets where the selected units are located and allow for a total possible number of movements to other territories. Each territory would be assigned a true value that never changes ( to label the territory)and your units have a maximum of 8 (octal) movements they can make at any time.
So in the case of the United States give it a value of say 3, whenever the units return the value of 3 for their location, you know that they are positioned in the United States. Then when you select a unit it will have a total possible moves of 8, so assign the value 0 through 3 to mexico and 4 through 7 to canada. You would have to make an array that houses all of the numbers of each territory and what octal value leads from each territory to the next.
hope this helps.
Follow this Question
Related Questions
How to make a player move along a fixed route 1 Answer
Random Modular Hex Board for board game 1 Answer
Filling a board with tiles, with separation 0 Answers
Adjacency information in geometry shaders 3 Answers
yield for animation 0 Answers