So I’m trying to match the type of movement that is implemented inside of tactical rpg games like Fire Emblem or Advance Wars. I currently have some code that I’ve coded that only covers basic movement relative to a movement stat.
local function CreateMovementTile(x,z)
local newSquare = movementTile:Clone()
newSquare.Parent = workspace.ActiveTiles
newSquare.Anchored = true
newSquare.Position = Vector3.new(unitPosition.X + x * 8, 1,unitPosition.Z + z * 8)
newSquare.Name = "MoveTile "..x..","..z
end
for i = 1, movement do
--Creates squares within all possible spaces within movements value spaces
--x and y values
CreateMovementSquare(i,0)
CreateMovementSquare(-i,0)
CreateMovementSquare(0,i)
CreateMovementSquare(0,-i)
for j = 1, movement do
if i + j <= movement then
--Everything in between
CreateMovementSquare(i,j)
CreateMovementSquare(-i,-j)
CreateMovementSquare(i,-j)
CreateMovementSquare(-i,j)
end
end
end
Which results in:
How would I expand this by making movement relative to the type of terrain like in here:
While Arden having 5 movement, he’s able to move a maximum of 7 squares because of reduced movement cost on roads. He can only move 4 spaces left because the forest costs 2 movement to traverse. Also I’m guessing if I going to implement this, I’m most likely going to need to use a custom pathfinding algorithm.