The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

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.

in Engine by (20 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

+3 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:
https://natureofcode.com/book/chapter-6-autonomous-agents/

There are also a lot of great examples here:
https://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732

by (22,191 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.