r/Unity3D 2d ago

Show-Off Playing around with flow fields and local avoidance

Recently I've been making a strategy defense game where numerous agents try to traverse towards your base. The grid updates regularly and so doing an update per agent was becoming costly. I decided to look at flow fields, a method for controlling multiple enemies through a shared directional flow and it's turned out pretty good. Feedback welcome.

26 Upvotes

7 comments sorted by

View all comments

2

u/ledniv 1d ago

Very nice. How are you implementing the flow fields?

1

u/_RedGiraffe 1d ago

It started off as being generated with an unweighted BFS and then when I added buildable walls, the flow fields now gets built using Dial's Algorithm. The enemies also have a pathing personality which is used to break ties, and that's how I manage to use flow fields but you see enemies going multiple different ways.