lampe-games / godot-open-rts

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

Inquiring : Swarm movements #56

Closed Georges-SR closed 1 year ago

Georges-SR commented 1 year ago

Greetings, awesome project, thanks a lot for all your work. Could you please explain in greater details how your multi-agent movement algorithm is working? - Is it boids?

Thanks again for all your work, please keep going, you're an inspiration! 🙏

Scony commented 1 year ago

hi,

everything is Godot 4 built-in except for the way I calculate target positions when moving more than one unit at the same time i.e. this: https://twitter.com/pawel_lampe/status/1621187942747086852

When multiple units are supposed to be moved to the position X I basically calculate the AABB of the swarm, take midpoint M, calculate offset vector of each unit pointing towards M, and then I use those offset vectors in a way that I subtract them from X - this way I get target position for each unit. There's also I additional trick - I attract new target positions of units to the X in a way they won't collide (I take radiuses into account). All that is done in: https://github.com/lampe-games/godot-open-rts/blob/main/source/match/utils/UnitMovementUtils.gd

Georges-SR commented 1 year ago

I see, thanks for the info and tips !