How do I start mapping legal moves and pathfind in a turn-based game?
Hello. I am working on a turn-based strategy game which is based on a grid of many blocks. Here is a code snippet of my terrain generation (keep in mind that some variables here are called earlier):
06 | local noise = 10 *math.noise(x/ 5 ,y/ 5 ,seed) |
11 | currentblock = "Grass" |
13 | currentblock = "Water" |
18 | biome = GetBiome(x,y); |
19 | size = B_I [ currentblock ] .Size; |
20 | canwalkon = B_I [ currentblock ] .CanWalkOn; |
22 | coords = Vector 2. new(x,y); |
25 | table.insert(terrain [ x ] ,y,blocktags) |
On the clientside, the 2d array gets visualized, and the player can invoke the server from there. I even made a remote function which the player can invoke to move a unit. My only problem, however, is deciding which moves are legal. Water, mountains, etc. should all block unit paths. Not to mention, each unit has its own movement points (aka the max blocks it can walk every turn). I wanted to use PathfindingService but I have no idea how to display SurfaceGuis on moves that are valid.
I just don't know where to even start.