Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour of NavigationAgent3D around NavigationObstacle3D #67712

Closed
sadovsf opened this issue Oct 21, 2022 · 8 comments · Fixed by #69988
Closed

Strange behaviour of NavigationAgent3D around NavigationObstacle3D #67712

sadovsf opened this issue Oct 21, 2022 · 8 comments · Fixed by #69988

Comments

@sadovsf
Copy link

sadovsf commented Oct 21, 2022

Godot version

4.0.beta3

System information

macOS Monterey 12.6

Issue description

When navigation agent should go around moving obstacles it almost seems it pushes into obstacle until it is no longer there (i tested it by disabling collisions on them but visually agent behaved the same). I would expect agent to try to "get around" dynamic obstacle rather than wait for it to clear.

Steps to reproduce

Option 1:
Have agent go around 2 obstacles that are moving up and down (not sure direction has effect) each being down at different time. Their movement is done using animation player animating position attribute of parent node like so:
Snímek obrazovky 2022-10-21 v 15 13 32

You will notice agent trying to get "through" obstacle rather than go around it.

Option 2:
Open repro project, start it and you can order red ball (agent) to go around level by lef mouse clicking on floor (clicking on purple walls and ramps will not react, only floor does).

Minimal reproduction project

Navmesh.zip

@smix8
Copy link
Contributor

smix8 commented Oct 21, 2022

Avoidance != Pathfinding

Avoidance does not change the pathfinding only the velocity. Your path insists that the agent moves through the obstacles und enforces this every single _physics_frame update.

3D avoidance shapes are radius / spheres. Your box / rect shaped obstacles only have this shape for visuals or physics collision but for avoidance calculation they are in fact very large spheres that only leave tiny gaps for the agent to move through when they are "up".

When the agent is close to the obstacle and the obstacle sphere moves down it "squeezes" the agent. The correct 3D avoidance would be to move through the floor but it obviously cant so it gives up with the suggested avoidance "safe_velocity" and moves on. If you have "ignore_y" enabled the safe_velocity will ignore the y-axis, so the agent basically stands still and waits for better times or until the obstacles moves its radius out of the overlap with the agent.

Avoidance and especially the obstacles are due for a rework for Godot 4, progress is tracked here.

@sadovsf
Copy link
Author

sadovsf commented Oct 24, 2022

I understand all this (i was author of c++ navigation integration for one of AAA titles released not long ago). What seems to be big problem for me is that avoidance sphere cannot be seen. Maybe drawing them at least as part of navmesh debug rendering, ideally even in editor would help a lot. Note i have Ignore Y enabled in agent props.

Btw so avoidance is using navmesh itself for avoiding obstacles (seems it is not the case) but then again, i dont see the sphere so it is har to debug what system see internally 🤔

Great work btw!

@Zireael07
Copy link
Contributor

Maybe drawing them at least as part of navmesh debug rendering, ideally even in editor would help a lot.

Good idea <3

@sadovsf
Copy link
Author

sadovsf commented Oct 24, 2022

I tried to add spheres roughly size that would encapsulate whole obstacle. There is visible enough space for agent to fit through when obstacle is up but it tries to push itself into it instead of going around using navmesh. Hope it helps with debugging.

image

@smix8
Copy link
Contributor

smix8 commented Oct 24, 2022

Yes, it is difficult to find good avoidance property values without any debug visuals. Debug visuals for the editor are on the "to-do" list. Even with good property values and setup it is difficult with the current avoidance to get a good result.

The RVO2-3D library currently integrated in Godot is intended for air, water or space agents and has issues with flat surface 2D avoidance in general as soon as things get more crowded or something pushes from above or below. It also has no support for hard-surface obstacles to build e.g. navmesh constrains. All current NavigationObstacles are just a (soft) avoidance radius created by a fake agent with some properties set at values that it can push most other agents but not all.

These are issues that are outside of what a user can control or change without digging into the source code. As shown in the linked rvo rework proposal there are a few things currently worked on that should improve the avoidance situation for Godot 4.

@sadovsf
Copy link
Author

sadovsf commented Oct 24, 2022

I see, thank you for great details!😊

Will be looking forward for further improvements then 👍

@smix8
Copy link
Contributor

smix8 commented Oct 25, 2022

The new avoidance is more detailed without much jitter if in close contact with an obstacle even when following the contour of moving avoidance obstacles very closely which should also help this issue here. There is no collision in this animation here, this is only avoidance movement.

rvo_obstacles8

@sadovsf
Copy link
Author

sadovsf commented Oct 25, 2022

Looks nice! Will test it as soon as it is available in beta build 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants