How do I return the path cost to the user?

0 favourites
  • 3 posts
From the Asset Store
You must carefully navigate the neon route and collect diamonds on the track.
  • I have a weird question but how do I return a path cost based on the user hovering over an area of the map (with mouse) that they would like to move their character? I am thinking of a game like Jagged Alliance 3 which shows AP cost to move before the user decides where to go. Once I understand how to capture the pathfinding cost, I can use some math to make a user friendly read out for the user.

    I read the pathfinding behavior documentation and I am generally familiar with pathfinding but in recent weeks, I've restarted my game after learning new techniques and now I am trying to learn more about pathfinding to better inform the user.

    I can return X,Y calculations and use the abs() with some fancy math to calculate the distance between the character's current location and the desired location but that is not the same as pathfinding cost. My way actually does work fine however not when I throw blocks in the way or costly terrain pieces.

    Side note: I understand Manhattan versus Euclidean distance if that helps. I teach ML/AI. Computer game design is just for fun.

    Thank you

  • If your game is grid-based, check out the EasyStarJS addon. It's pathfinding for tilemaps. It has lots of features, you can set different costs for different tiles and it can return the total path cost.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you. I'll check it out!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)