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

NavigationAgent ignores NavigationObstacle #76670

Closed
Vosnov opened this issue May 2, 2023 · 8 comments
Closed

NavigationAgent ignores NavigationObstacle #76670

Vosnov opened this issue May 2, 2023 · 8 comments

Comments

@Vosnov
Copy link

Vosnov commented May 2, 2023

Godot version

4.0.2.stable.official

System information

Windows 10, NVIDIA GeForce GTX 1660 SUPER, Vulkan

Issue description

NavigationtArget doesn't find a workaround and tries to go through NavigationObstacle as if it doesn't exist. Avoidance enabled
= true. All settings by default. The problem is reproduced in both 2d and 3d

Steps to reproduce

image
image

Minimal reproduction project

Test.zip

@AThousandShips
Copy link
Member

AThousandShips commented May 2, 2023

Does this happen if you don't set the target position every frame? You're not supposed to set it constantly as it recomputes the path

Resetting the path every frame (by accident) might get the actor to stutter or spin around in place.

@AThousandShips
Copy link
Member

You also set a very high velocity when the distance is high, I suggest normalizing it

@smix8
Copy link
Contributor

smix8 commented May 2, 2023

Resetting the path every physics_frame with a new target_position is indeed a problem as it destroys any path consistence or direction.

I do not think that this is the main or only problem as the current avoidance resets every frame anyway so it lacks consistence in velocity as well.

If you can try testing with pr #69988 that fixes most of those issues.

Also lowering the time_horizon might help cause currently with the defaults you are predicting the velocity for an entire second at 100 px speed which gives your agent very little room to maneuver in that layout at that resolution. If agents can not find a workable solution they often break and move at very slow or erratic velocities.

@Vosnov
Copy link
Author

Vosnov commented May 2, 2023

I moved the target position to func _ready, normalized the vector, and lowered the time_horizon. And it still didn't help

@smix8
Copy link
Contributor

smix8 commented May 2, 2023

So I had time to test the project now. While using a NavigationObstacle for something static is in general not recommended it is not the main issue. The issue is that ...

a) The agent has a radius of 80 pixel but the NavigationAgent2D only has a radius of 10 pixel so it thinks it can move around the obstacle radius at that smaller size but gets stuck on physics collision.

b) NavigationObstacle2D estimate_radius is a useless property that fails a lot calculating a proper radius so it should not exist. This property gets removed in the linked avoidance rework for exactly such reasons. Set it to a manual radius a little larger than the size of your object so you have some avoidance margin. E.g. in my test 100 worked fine.

c) Since the avoidance will push the agent away from the ideal path it is also required to increase path_desired_distance and path_max_distance to avoid the agent resetting its path all the time which can make it get stuck. E.g. in my test 120 for path_max_distance and 250 for path_max_distance worked fine.

@Vosnov
Copy link
Author

Vosnov commented May 2, 2023

In version 4.1 it works much better, but in 4.0.2 these settings did not give any result. Anyway, thanks a lot for the help

@smix8
Copy link
Contributor

smix8 commented May 2, 2023

Properly due to #74893 which made it to 4.0.2 that affected obstacles which was fixed in 4.0.3 with #75756.

@Calinou
Copy link
Member

Calinou commented May 2, 2023

Closing per @smix8's comment, as this will be resolved in 4.0.3.

@Calinou Calinou closed this as completed May 2, 2023
@Calinou Calinou added this to the 4.0 milestone May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants