Cortex-Command-Community-Project icon indicating copy to clipboard operation
Cortex-Command-Community-Project copied to clipboard

Jetpack/Jump-Aware Pathfinding

Open Causeless opened this issue 6 months ago • 0 comments

This PR adds the capability to the pathfinder to intelligently generate paths based on the actor's jump height (i.e, how far vertically they can fly using their jetpack).

Previously, actors would pathfind without any sort of awareness of the ground. They pathfinder would generate a path through air assuming that everything can fly. Then a series of hacks were applied to clean up the path: we'd move all the points in the path down to the ground, and then the Lua AI would try to reconstruct "jumping" by moving the points back up where necessary.

This would very often generate paths are are impossible for the actor to follow, for example pathing up-and-around an entire building. This frequently led to bugs where actors would fly up-and-down on the spot without actually making any progress towards their destination. It would also generate very bad paths even when the actor has adequate jetpack strength, due to the varied hacks to cleanup the path.

With this change, actors now generate paths that stay on the ground naturally during the pathfinder itself, instead of needing to cleanup the path. They also generate jumps within the pathfinder, meaning that the actor understands much better how to navigate upwards. For example, actors will now try to use intermediate platforms to work their way upwards, if in a long vertical shaft with stopping points to stand on. Likewise. if an actor sees that it's absolutely impossible for them to jump up to a ledge to enter a base, they will now dig through the walls if necessary.

The pathfinder also has support for NoGrav areas, so all actors understand that they can pathfind up through movators, even without jetpacks. Support for flying pathfinding is still included, for example for dropships.

~Just now it's hardcoded to assume that crabs have zero jump height, that humans have a fixed jump height, and that everything else (dropships, rockets, etc) are flying. Before merge I will add code to automatically calculate a jump height based on the actor's mass and their jetpack fuel and thrust.~ Now the game uses an internal miniature iterative physics sim to calculate jetpack jump heights automatically. This is dynamic, so even takes into account the current actor's inventory mass.

Causeless avatar Aug 22 '24 11:08 Causeless