this post was submitted on 04 Dec 2024
22 points (100.0% liked)

Godot

6005 readers
35 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

[email protected]

Credits

founded 2 years ago
MODERATORS
22
submitted 2 weeks ago* (last edited 1 week ago) by Zykino to c/godot
 

I have been looking for a way to move non player entities on the map. For example I want cars to move around road, a parking lot, … I found way too many options without comparaison to see pro/cons. Is there a ressource telling which option is privileged?

I saw (in 2D, but I suspect all/most have their 3D equivalent):

Option My understanding
Path2D Very rigid path to follow (only saw used with tween). Can be nice to follow tracks, insert cubes in slot, … But when trying to have a more natural movement, with a bit of variety thanks to physic I don’t see how to do it.
AStar2D (and the AStar2DGrid variant) Robust algo known everywhere. Can add weight to connections. I suspect to make it work we have to give points to reach so we should "cover" the maps with points and link them together
NavigationServer2D Same as AStar2D but experimental, more automatic. Instead of specifying all the point we specify accessible zones. But adding weight to the connection is less obvious (using NavigationObstacle2D?) may be less customizable also?

Are there more options?
Is my understanding of each correct or completely wrong?
What is "the best" one (in Godot 4.3)? Like is there big performance drawback for some (at 100 entities there are lags or whatever)?

Keep in mind that I want my game as little as I can to understand how Godot/game engines work (I’m a developer so that part is easy, Scenes and Nodes choice less so), I don’t really care if using experimental feature means it disappear at some point or change behavior.

Edit: Just found out the official page explaining the different methodes.
So AStar is for grid/pathing on a set of points while NavigationServer can navigate to any point on the accessible area and uses A* as an implementation detail.

=> I think for my use case A* is better suited since I want to move on roads (that look like a grid with weight being the length).

you are viewing a single comment's thread
view the rest of the comments
[–] Zykino 1 points 1 week ago

Thanks. I think your message is not very clear at first (since I did not know about "nav mesh"). But reading Wikipedia is clear now. It also helped me find the official page (added the link in the post).