Announcement

Collapse
No announcement yet.

Grid Based Movement - Add wait in pawn's moveto location loop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Grid Based Movement - Add wait in pawn's moveto location loop

    Hi Guys!

    I'm working on a grid based movement in turns, expecting different spaces on the grid to have different move costs based on terrain, diagonal movement, other obstacles, etc.

    So on each pawn's turn I run a dijkstra function to find which spaces are reachable and the most efficient path to each. When a destination is clicked on, I put the steps to get from a to b in an array and then do a foreach loop to have the pawn move each step of the way using a navmesh.

    The pawn certainly gets there, the problem is that it follows the navmesh's most direct route to the last destination instead of the dijkstra map I build; which might be a longer path but cheaper in game rules.

    I'm guessing the loop runs too quickly and by the time the pawn takes it's first step it's already trying to reach the last destination and thus follows the navmesh path instead of mine. I'm quite new at this but I think if I could add a wait on the foreach loop so it doesnt move to step 3 before actually reaching step 2 it would work properly.

    Ideally this would be based on pawn getting somewhere instead of juggling miliseconds, so it can be easiliy adapted to future changes, account for different unit speeds, etc.

    Am I approaching this the wrong way? Is there an easier way?

    Thanks for all your wisdom guys!
Working...
X