lampe-games / godot-open-rts

Open Source RTS game made in Godot 4
https://lampe-games.itch.io/open-rts
MIT License
494 stars 70 forks source link

Units can move out of bounds #69

Closed domenukk closed 8 months ago

domenukk commented 11 months ago

When many units move close to the edge of the screen, some get pushed out of bounds, see screenshot:

image
Scony commented 11 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.

smix8 commented 10 months ago

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)
Scony commented 10 months ago

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!

Scony commented 8 months ago

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.

Scony commented 8 months ago

With latest Godot master the issue is fixed for air units as well.