Turn based strategy game.
Character can move through water and land.
I've built a small tilemap, with water and land tiles.
I've built an AStar, with each point connected to it's neighbor, including it's diagonal neighbor.
Bidirection movement between points is enabled.
I have set weights for each point:
Land tile weight = 2
Water tile weight = 3
Here's a section of the tilemap:
- Weights are shown
- "x" is my character
- "o" is where I want my character to go to
Say the character has 20 movement points. If I call
get_point_path(id of "x", id of "o") I would get this path:
With the character having 5 movement points left over.
(e.g. 20 -2 -3 -3 -3 -2 -2 = 5)
How can I modify my AStar (or add a new Astar or whatever) so that moving from land tile to water tile has a tile weight (movement cost) = 6? But, when moving from a water tile to water tile, the tile weight remains = 3?
With the tile weight for land to water in place:
With the character having 2 movement points left over.
*(e.g. 20 -2 -6 -3 -3 -3 -2 -2 = 2)
Solutions I have considered:
- Make all coastal water tiles have a weight = 6; But now, if character was in the water, moving along the coast would be 6 movement points each tile instead of the desired 3.
- Create two AStar IDs with the same "position". Have one be of weight 3 and one of weight 6. Have a "one-way" directional connections from land to the water tile of weight 6. Have a "one-way" directional connections from water to water with weights of 3. Not sure that Astar can handle this specific set-up properly though... maybe I need to use
get_point_position() instead for this to work.