Serveral questions related to tile based movement in a 3D environment

My idea is to divide the 3D space on the X and Y axis into squares, lets say 1x1 unit is a square for example. The goal is to be able to create round based games like Space Crusade (board game) but also games like X-Com Terror from the Deep or Jagged Alliance. I don’t want to take the Z axis in to be able to let the pawns walk over uneven terrain and stairs for example.

To check which players turn it is I thought to have a game object that knows the order of players and which player the actual turn plays. The pawns in the game would be assigned to the player. This should work for single and multilayer (with a dedicated server), should it not?

Now I have several questions. When you answer them please consider that I am a Unity3D newbie, I’m familiar with programming but not Unity3D and calculating things in a 3D space. So if possible for you please provide me links to articles and API documentation (I know the API URL, i mean certain classes/methods I’ll need), whatever is helpful for me to understand how to do what I want in unity 3D.

  • Is my concept good for what I want (movement and turns) and doable?
  • How can I calculate visibility of enemies?
  • How can I calculate a path? Specially if its a path to the upper floor which involves a stair?
  • How can I snap the selection to a tile in the “grid”? Are projectors and an image with alpha transparency the way to go?

Thank you in advance! :slight_smile:

Stairs would be completely arbitrary in this kind of a setup. There are a lot of good articles on 2D game design out there, but you also have the advantage of a 3D worldspace, and 3D rendering handles 2D sprites much faster than a raster setup would.

You are going to need to do some sort of depth sorting, but it would be easier to just move your flat sprites up on the z axis by a really tiny bit based on their layer. Multiple floors and whatnot can actually be handled by using the Z axis, and using either an orthographic camera that you move up and down based on what floor it is looking at.

Calculating enemy visibility is a pretty tough one actually. You are going to have to do some manual raycasting in order to determine dense tiles in between the user and the enemy.

For pathing, you are going to want to take a look at the A* algorithm (A-star). The great thing about A* is that it can be scaled up if you implement it with multiple levels of detail and are clever with compressing and reusing previosly solved paths. Pathfinding is sort of a voodoo section of code. Not many people have ever managed to do it well on a massive scale. There is a certain satisfaction in getting good with it though, as you can do some amazing things with the algorithm. Stairs are a cinch once you understand that A* is scalable to any dimensional layout, unitary grid, any pattern (even irregular), and any data set. As long as you can traverse the data set, you can A* it.

Snapping is completely arbitrary. I’d recommend a projector for the easy solution, and again, think about it, working in 2D is the same thing as working in 3D. There’s no reason you need regular tiles in a 2D game, and there’s no reason you can’t use them in 3D games. So really, it’s a matter of creating an algorithm that will convert the x/y values to the proper value using overly simple math.

Your theory is mostly pretty spot on, you just need to read some tutorials on blitting, mapping, and pathfinding. You’ll find that Unity’s system is similar to creating a 2D game in ActionScript3. My advice is to dissect some ActionScript/Flash game tutorials and then convert them to the applicable cs/js/boo syntax and Unity API.