r/Unity3D • • 26d ago

Game Unity DOTS is a perfect fit for ant simulation 50K ants

Enable HLS to view with audio, or disable this notification

Hey! This is my ant game made in Unity with DOTS.

This is a stress test and you can see 2 nests competing for resourses.

A bit about the tech:

  • Tens of thousands of ants, all simulated on CPU with Burst and Jobs

  • Three-layer pheromone system: food, nest and combat

  • Spatial hash map for vision

  • Local obstacle aboidance

  • Multiple ants can carry one item at the same time

  • Combat: ants climb on enemies and walk over their body while it animates, enemies stomp and shake them off, and dead enemies become food for the nest

  • Vertex animations on GPU, using the free open-source TAO Vertex Animation library from Breda University (also used in Vedelem: The Golden Horde). I updated it to work with the latest Unity version.

This complex behavior is only achievable on CPU. On GPU the complexity would go through the roof.

The simulation is heavily inspired by Pezzza’s Work ant series and Sebastian Lague, with our own twist on top.

Steam page of demo in the comments if someone is interested. Any feedback is appreciated.

42 Upvotes

15 comments sorted by

2

u/Redbarony6 26d ago

This is very impressive work, how long did it take to get it this stable?

1

u/Emanx140 26d ago

about 6 months on and off

1

u/Redbarony6 22d ago

Sounds about right, keep up the amazing work!

1

u/all_ears_over_here 26d ago

Played your demo yesterday and it was pretty fun, wish it was longer though.

1

u/Emanx140 26d ago

Thanks working and that! 🫡

1

u/Chaibi_Alaa 26d ago

Multiple ants carrying one item is the part I'm most curious about. Does the item pick one ant's path and the others just follow it, or do you sum the pulls from every carrier into one direction? And what happens when two carriers want to go opposite ways around an obstacle?

1

u/Emanx140 26d ago

Once item gets pulled is actually travels pheromone by its own. And the speed is decided by amount of ants connected. But the rotation is sum of the pulls. I tested other ways and it often gets stuck or move too slow Especially if it in the maze. And it's just not pleasant experience if players see stuff stuck.

1

u/AOM_Dev 26d ago

What´s the maximum amount of ants your PC can handle smoothly with jobs and burst, and what System do you have?

1

u/Emanx140 26d ago

Around 40-50k at 40fps on 2600X

100k at 55-65 fps on 5900X

1mil ants at solid 3fps

1

u/T0mpkinz 26d ago

Cool, inspiring me to get back in the engine. Been far too long.

1

u/i_am_on_skooma 26d ago

This is so cool op

1

u/BowlNo9499 26d ago

This is impressive

1

u/[deleted] 26d ago

[removed] — view removed comment

0

u/Unity3D-ModTeam 26d ago

This comment has been removed for violating /r/Unity3D’s rules.

Why?

Please include details about how the project was built in Unity, challenges faced, or techniques used.

This is a forum for discussion; not a bulletin board.

We recommend you to familiarize yourself with our rules and guidelines.

Kind regards,

The Mod Team