0 votes

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.

asked Jan 1 in Engine by danii956 (19 points)

https://github.com/godotengine/godot/issues/3130 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.

1 Answer

+2 votes

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:

answered Jan 1 by kidscancode (17,668 points)

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.

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.