Skip to content

Sh1co/Unity-DOTS-Battle-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity DOTS Battle Simulator

A high-performance, large-scale real-time strategy (RTS) battle simulator built in Unity using Data-Oriented design principles. Simulate tens of thousands of autonomous agents at playable frame rates by leveraging DOTS, parallelism, and custom pathfinding and scheduling optimizations.


Features

  • Massive Scale Run battles with 100K+ units on desktop and 30K+ on laptop hardware without dropping below 30 FPS.

  • Data-Oriented Architecture (DOTS) Entities & Component System (ECS) for cache-friendly memory layouts.

  • Multithreading & Burst C# Job System schedules workloads across all CPU cores; Burst compiler transforms hot code paths into highly optimized native SIMD instructions.

  • Flow-Field Pathfinding Precompute a global vector field guiding all units toward goals in O(G + N) time, replacing per-unit A* queries.

  • Grid-Based Spatial Partitioning Divide the map into discrete cells to localize collision checks and enemy searches, dramatically reducing per-unit query costs.

  • Staggered Updates Spread AI, targeting, movement, and attack logic over multiple frames to smooth CPU usage and eliminate frame-time spikes.

  • Off-Screen Entity Culling Throttle or skip expensive logic (projectile simulation, AI updates) for entities outside the camera frustum.


Getting Started

Requirements

  • Unity: 6.0 or later

  • Packages:

    • Entities
    • Burst
    • Jobs

Installation

  1. Clone this repository:

    git clone https://github.com/Sh1co/Unity-DOTS-Battle-Simulator.git
  2. Open the project in Unity Hub.

  3. Set the unit counts in the AllyStart and EnemyStart gameObjects

  4. Press Play in the Editor.



Performance

Benchmarks on a high-end desktop (i9-14900KF, RTX 4090) sustain > 30 FPS with 134 000 agents, compared to ~ 4 200 agents in the naïve implementation. On a laptop (i7-9750H, GTX 1660 Ti), the optimized build holds ~ 30 FPS at 38 000 agents.


Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

Acknowledgments

Based on the master’s thesis “Scalable Battle Simulations in Strategy Games: Evaluating Optimization Methods in Unity” by Sherif Nafee.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published