I am making a game similar to RimWorld where anything that is on a particular tile, including that tile, can affect movement speed. Everything has a
MoveSpeedMultiplier (0 is unwalkable, 2 is twice the walking speed) that adds up to the final value. I will try to concisely explain what I’m doing just to make sure this is the way it needs to be done.
MoveSpeedMultiplier for 2 scenarios:
- Dirt tile (0.9) + Food (0.9) on the ground = 0.9*0.9 = 0.81.
- Shallow water tile (0.2) + floating baggage (0.6) = 0.2*0.6 = 0.12.
Then, these added-up values are calculated into TraversalCost (using 1000 as the base value for traversing a single tile).
- 1000 / 0.81 = 1235 (1.2 times more expensive to walk over)
- 1000 / 0.12 = 8334 (8.3 times more expensive to walk over)
TraversalCost values are assigned to
NodeCost in every single node data (my own class).
Finally, I assign these costs via my custom
TraversalProvider, like so:
Now I want my characters to take into account the
TraversalCost when calculating a path from their location to some other location. I use
AIPath, but I couldn’t get it to work with the custom traversal provider.
I got it to work using seeker:
Is there any way to make custom traversal providers work with
AIPath, or do I have to use
Seekerlike shown in the example above? If I do use seeker, do I manually have to apply all the modifiers that I use?
I use multithreading. To pathfind across a 400x400 map, this method takes about a second to calculate. Am I doing everything as optimally as I should be, or is there any part of this that I can improve?
This is a crucial part of my game. Massive gratitude for your time and an amazing asset.