I am working on a 2d strategy game for a school project and need some advice on how to code a tile based movement system. I have a system in place that allows the player to see where a specific unit can move when clicked on. I got this to work by showing UI sprites that mark the spaces the unit can move to when the unit is selected. Other than that, I have nothing else and am not sure how to code the movement. Any ideas?
That’s a pretty general question.
I would 1st look into A* path finding to define a route and then worry about moving along the found path (which is just interpolating between every tile our path is made of)
If you want to interact with these grids I would place colliders on each tile and use a raycast from the camera to the mouse position and detect the colliders by tag or something then you can have some code fire off on a mouse click depending on where you press, should get you started. Since it’s a school project I imagine you won’t have much time to implement stuff so I wouldn’t do anything too complicated like the A* algorithm because that would take a long time to learn just by itself.
Funnily enough, I was able to get the movement system working about 10 minutes after posting this. Thanks anyway though.
lol that’s pretty much standard procedure for programmers when they have a problem, done it myself numerous times.