Closed domenukk closed 8 months ago
Yeah, that is the corner case that Godot 4.0 was unable to handle. I believe @smix8
introduced a simple mechanism where it's possible to add boundaries to the underlying RVO2 simulation thus preventing this issue.
I'll check how to enable it and hopefully it will be resolved.
You can add a static navigation obstacle for each of the used navigation maps that you want the avoidance velocities to be limited.
var map_bounds_obstacle: RID = NavigationServer3D.obstacle_create()
var navigation_map: RID = # whatever navigation map RID you use
NavigationServer3D.obstacle_set_map(map_bounds_obstacle, navigation_map)
var map_bounds_outline_vertices:PackedVector3Array = PackedVector3Array ([])#
# Add an array of Vector3 positions of your map bounds here
# The winding order determines if the agents are pushed out or sucked in by the obstacle
NavigationServer3D.obstacle_set_vertices(map_bounds_obstacle, map_bounds_outline_vertices)
NavigationServer3D.obstacle_set_avoidance_enabled(map_bounds_obstacle, true)
You can add a static navigation obstacle for each of the used navigation maps that you want the avoidance velocities to be limited.
var map_bounds_obstacle: RID = NavigationServer3D.obstacle_create() var navigation_map: RID = # whatever navigation map RID you use NavigationServer3D.obstacle_set_map(map_bounds_obstacle, navigation_map) var map_bounds_outline_vertices:PackedVector3Array = PackedVector3Array ([])# # Add an array of Vector3 positions of your map bounds here # The winding order determines if the agents are pushed out or sucked in by the obstacle NavigationServer3D.obstacle_set_vertices(map_bounds_obstacle, map_bounds_outline_vertices) NavigationServer3D.obstacle_set_avoidance_enabled(map_bounds_obstacle, true)
Thanks!
This issue is fixed for terrain units now. What's interesting, however, is that it does not work for the air units despite the fact that the implementation of obstacles is the same... So it's probably a Godot bug. I'll check that and fix in Godot if necessary.
With latest Godot master
the issue is fixed for air units as well.
When many units move close to the edge of the screen, some get pushed out of bounds, see screenshot: