godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.22k stars 19.98k forks source link

NavigationAgent3D receives safe_velocity vectors that are the opposite of safe #48025

Closed smix8 closed 2 years ago

smix8 commented 3 years ago

Godot version: Godot 4.x commit 29775a1714d01f35570ef708d24a1cde77aa1a5a

OS/device including version: Win 10 64x

Issue description:

NavigationAgent3D receives safe_velocity vectors that are the opposite of safe from the collision avoidance algorithm calculated by the NavigationServer3D.

The returned safe_velocity actively attempts to push agents off the baked navigation meshes or even down cliffs without any collision geometry below.

RigidBody3D agents that move directly with calculated safe_velocity are immediately stuck and lost forever because they fall out of the map. KinematicBody3D agents can be saved but require additional raycasts to stay on the map because the collision avoidance tries to actively kill them.

It seems the only thing the algorithm cares about are other agents in the area of the agents path_max_distance. It treats the entire gameplay scene as a walkable, flat plane, completely ignoring both the baked navigation meshes as well as the bakesource collision geometry. It is like implementing car navigation without considering streets and adding landmines on the map for cherry.

Steps to reproduce: Not producable without #48028 merged cause NavigationAgent3D callbacks are broken for months now.

I only just fixed the callback issue to find out that with "working" callbacks the collision avoidance calculation on the NavigationServer is a malicious agent murder machine that should be returned to its creator.

Minimal reproduction project: Not producable without #48028 merged cause NavigationAgent3D callbacks are broken for months now.

christinoleo commented 3 years ago

@smix8 thanks very much for #48028, I tried to make a fix myself but had absolute no success on understanding that code. To add to the discussion:

I don't know anymore what is expected from the navigation system and what is expected for game devs to implement due to custom behaviour, but by my tests, I unfortunately can't use it at all. Maybe I'm missing something?

This is the project I used: aoe.zip

ezgif-2-c58382452bbf

smix8 commented 3 years ago

@christinoleo Navmesh baking issues are not directly related so better open another issue for this. I can't tell what is a bug or a feature with CSG nodes.

I had no issue after the fix to get my agents to react with collision avoidance technically and move around each other. The endresult in movement behavior is just not very usable in practice if your game is not placed in a desert on a flat plane. Maybe your agent issue is scripting related. See my post here for basic movement examples for Node3D, KinematicBody3D or RigidBody3D actors.

christinoleo commented 3 years ago

Yes, I saw your examples in that post. My code is using the exact same logic as the Kinematic3D version of it. Oh well, I will wait and see if other updates fixes this behaviour in a month or so. BTW I think those codes are a great fit for documentation/tutorial, in case they aren't already in some documentation somewhere!

smix8 commented 3 years ago

They are not rightnow. I plan to add them to a documentation PR if no one beats me to it.

For an RTS like gametype like your mini demo I would work with movement formations to begin with and not rely on navmesh based collision avoidance as it always ends in a disaster movement.

smix8 commented 2 years ago

Closing cause there are multiple similar issues open.