2D pathfinding without using TileMap or Navigation2D since obstacles are free-moving RigidBody2Ds

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By danii956

I have a spaceship RigidBody2D that moves towards a player RigidBody2D but I need the spaceship to avoid the planet RigidBody2Ds using pathfinding.

The issue with using TileMap is that each tile is static and stationary while I planned the planet RigidBody2Ds to move via physics process. Furthermore, I don’t think there is a way to tile a rigid body anyway.

I don’t think using Navigation2D node with NavigationPolygonInstance will work as well since it only allows pathing defined in areas indicated by NavigationPolygonInstance. Obstacles are free-moving rigid bodies and in confined area.

I have included an image that gives a clearer picture. I’ve been scratching my head over this and I would be thankful if a step in the right direction is given.

NavigationMesh dynamic obstacle detection · Issue #3130 · godotengine/godot · GitHub maybe one day.
As of now I’d suggest using waypoints by having 4 points/areas around the planet. As the ship gets nearer to the planet find the nearest waypoint and then find the next waypoint depending on which way the ship is facing, after that it should’ve navigated around the planet enough to follow the player again.

Magso | 2020-01-01 20:03

:bust_in_silhouette: Reply From: kidscancode

Steering behaviors are the answer to this kind of thing. Specifically in this case the “leader following” and “obstacle avoidance” behaviors.

The good news is they’re relatively easy to implement. If you’re not familiar, the absolute best place to learn about them is here:

There are also a lot of great examples here:

I vote for a tutorial/example for this applied to godot, it will help a lot of lads, steering, flock and grouping in general. Godot is also building a new navigation system for 4.0 right? If I am not mistaken, they talked about wanting implemented obstacle avoidance.

The_Black_Chess_King | 2020-01-02 03:58

There are a couple out there - GDQuest for example, and I’ve used them in several different tutorials.

As for what may or may not be coming in 4.0, and what form it will take when it does, that’s just speculation and discussion at this point.

kidscancode | 2020-01-02 18:21