- Home /
3D Grid Based Movement (X-Com 2012 etc) – How to implement vertical movement?
G'day all,
I'm in the early stages of developing a simplified version of the modern X-Com games in unity. Not sure if it'll turn into anything more than a passion project, but it's a fun goal to have.
Anyway, I'm in two minds about how to implement the gridbased movement – especially considering that I need units to move up and down as well as forward, back, left and right. Worrying mostly about finding paths at the moment, less about actually moving anything.
My first approach is to just create a 3D array grid and use standard A* pathfinding to control movement. My question here is how do I deal with ramps and staircases etc. Basically, how do I specify WHERE units can go up and down and how they should move. And what do I do with all those wasted array cells that won't ever be used because buildings don't tend to be the size of a whole map...
The other potential method is to create multiple 2D array grids and use A* coupled with the ideas here: https://indiewatch.net/2016/05/28/tutorial-multi-grid-graph-navigation-in-unity/ to move between those grids. Though the issue here is that I'm still not sure how best to manage the actual process of moving up and down.
Does anyone have any tips? There are a lot of tutorials on YouTueb for this but NONE of them seem to cover moving units up and down, just left and right. Even if they DO show movement up and down it's never explained.
I've seen some images on google/here with users having lovely geometry hugging grids that allow units to move up and down ramps etc – I'm very jealous!
In theory, moving up or down is not any different than moving on the ground, as far as pathfinding is concerned. The node doesn't care if it's connected to another node that's higher or the same level. From my own experiences, since you have a grid or rather cell-based layout, I would just declare the position(s) of any pathfinding nodes with the type of ground tile that sits at a certain position. So, a normal ground tile would have the node position right at it's center, while a ramp would have it higher up so it sits where the mesh of the ramp is.
Your answer
Follow this Question
Related Questions
How can I get my pathfinding algorithm to know that it cant go through certain sides of tiles 1 Answer
Moving only if straight path dijkstra 1 Answer
Turn-based-RPG-styled movement area color change 1 Answer
How can I make 3d grid based movement for a strategy game on the y axis 0 Answers
Help with RTS style controlls. 1 Answer