{"id":14959756,"url":"https://github.com/unity-technologies/dots-training-samples","last_synced_at":"2025-05-15T08:02:59.709Z","repository":{"id":35085010,"uuid":"188308406","full_name":"Unity-Technologies/DOTS-training-samples","owner":"Unity-Technologies","description":"Samples designed as exercises to be ported from Unity GameObjects/MonoBehaviours to Unity DOTS. ","archived":false,"fork":false,"pushed_at":"2024-10-07T07:11:49.000Z","size":699325,"stargazers_count":1588,"open_issues_count":5,"forks_count":360,"subscribers_count":599,"default_branch":"master","last_synced_at":"2025-04-03T17:06:52.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Unity-Technologies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-23T21:21:28.000Z","updated_at":"2025-04-03T05:02:12.000Z","dependencies_parsed_at":"2023-02-18T06:16:01.646Z","dependency_job_id":"d2fb6810-3d33-4e65-9f7f-91541a878245","html_url":"https://github.com/Unity-Technologies/DOTS-training-samples","commit_stats":{"total_commits":172,"total_committers":40,"mean_commits":4.3,"dds":0.8953488372093024,"last_synced_commit":"b9ec219eb74c8a861aaecc86a2274785e5d7bb87"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FDOTS-training-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FDOTS-training-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FDOTS-training-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FDOTS-training-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Unity-Technologies","download_url":"https://codeload.github.com/Unity-Technologies/DOTS-training-samples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248390016,"owners_count":21095710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:20:43.279Z","updated_at":"2025-04-11T11:50:58.163Z","avatar_url":"https://github.com/Unity-Technologies.png","language":"C#","readme":"Under the 'Originals' directory, you'll find small simulations/games implemented in classic (non-DOTS) Unity. Your task is to implement one of these samples in DOTS.\n\n1. Clone this repository.\n2. Make a new branch for your sample port.\n3. Create a new Unity Project and place it under the 'Ported' directory, *e.g* /Ported/AutoFarmers/\n4. Configure the project for DOTS.\n\nFeel free to copy assets and code snippets from the originals into your ports. The focus of this exercise is to familiarize yourself with the DOTS API and to practice Data-oriented Design principles!\n\n## Sample Gallery\n\n*Expand the arrows for more details about each sample.*\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eAnt Pheromones\u003c/strong\u003e: Ants look for food and spread pheromones to influence the pathing of other ants.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n  \n  \u003cul\u003e\n\u003cli\u003eAnts bring food from the source (green spot) to the destination (red spot).\u003c/li\u003e\n\u003cli\u003eEach ant spawns at the center point with a random heading.\u003c/li\u003e\n\u003cli\u003eAnts bounce off of walls at the inverse angle.\u003c/li\u003e\n\u003cli\u003eAnts will steer towards the food source (green dot) if they have line of sight.\u003c/li\u003e\n\u003cli\u003eAnts leave pheromone in the spots they walk over.\u003c/li\u003e\n\u003cli\u003eAnt steering is affected by pheromones, goal location (food or nest), obstacle avoidance and obstacle \"bounce\".\u003c/li\u003e\n\u003cli\u003ePheromone at a spot decays over time.\u003c/li\u003e\n\u003cli\u003eAnt steering is also slightly randomized, so ants don’t walk in straight lines.\u003c/li\u003e\n\u003cli\u003eThe gaps in the ring walls randomly vary in size and placement.\u003c/li\u003e\n\u003cli\u003eKeyboard controls allow the user to slow down, speed up, and reset the simulation.\u003c/li\u003e\n\u003cli\u003eThe amount of pheromone an ant drops depends on the speed of the ant, and the speed depends on steering.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\n![Ant Pheromones](_imgs/AntPhermones.gif?raw=true)\n \n---\n \n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eAuto Farmers\u003c/strong\u003e: Farmers gather and sell resources to expand their farm.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n  \n   \u003cul\u003e\n\u003cli\u003eOn start, a single farmer (the green cylinders) spawns.\u003c/li\u003e\n\u003cli\u003eFarmers walk around to destroy rocks (the grey cylinders) to make way for tilling the soil (creating brown-striped crop cells).\u003c/li\u003e\n\u003cli\u003eA plant grows in each crop cell. (The color and mesh of plant randomly varies.)\u003c/li\u003e\n\u003cli\u003eWhen fully grown, a plant is ready for harvest by a farmer. Farmers deposit plants in the nearest silo (grey-blue cylinder).\u003c/li\u003e\n\u003cli\u003eWhen enough resources have been collected into a silo, a new farmer spawns from the silo.\u003c/li\u003e\n\u003cli\u003eFarmers look for their next task in a limited radius. If no task is found, they look in an increasingly larger radius until a task is found.\u003c/li\u003e\n\u003cli\u003eFor every fifth farmer spawned, a drone is spawned instead.\u003c/li\u003e\n\u003cli\u003eDrones fly and harvest plants. They do not destroy rocks or plant crops.\u003c/li\u003e\n\u003cli\u003eAfter depositing, drones hover over the silo until they locate a plant to harvest.\u003c/li\u003e\n\u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n \n![Auto Farmers](_imgs/AutoFarmers.png?raw=true)\n \n---\n \n \u003cdetails\u003e\n   \u003csummary\u003e\u003cstrong\u003eBucket Brigade\u003c/strong\u003e: Firefighters pass buckets along a chain to extinguish a fire.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n     \n   \u003cul\u003e\n\u003cli\u003eEach cell of the grid has a temperature from 0.0 to 1.0. Cells above 0.2 are on fire and transmit heat to their neighbors. The color and height of a fire cell reflects its temperature. (For visual effect, a fire cell's height randomly oscillates a small amount, but this does not reflect its actual temperature.)\u003c/li\u003e\n\u003cli\u003eOn start, a few random cells are on fire. Buckets are randomly placed around the field.\u003c/li\u003e\n\u003cli\u003eWorkers are grouped into teams. Each team picks the closest cell on fire and forms two lines from the fire to the nearest water (blue cells outside the field). One line passes full buckets; the other passes empty buckets.\u003c/li\u003e\n\u003cli\u003eEach team has a bucket fetcher, who retrieves the nearest bucket, walks it to the water at the end of the line, fills the bucket, and then drops it.\u003c/li\u003e\n\u003cli\u003eWorkers in the 'pass full' line look for full buckets on the ground within a small radius. When found, they walk over, pick up the bucket, carry it to the next worker up the line, and drop it. The last worker in the 'pass full' line empties the bucket on the fire (lowering the temperature of that cell and its eight surrounding cells to zero). Workers move slower while carrying a full bucket.\u003c/li\u003e\n\u003cli\u003eWorkers in the 'pass empty' line behave the same but only carry empty buckets.\u003c/li\u003e\n\u003cli\u003eEvery frame, a team will reposition its line to the fire cell closest to its current water source.\u003c/li\u003e\n\u003cli\u003eWhen a team's water source is exhausted, it repositions the line to the next closest water.\u003c/li\u003e\n\u003cli\u003eWhen repositioning, a worker will not resume its normal behavior until it has reached its new position.\u003c/li\u003e\n\u003cli\u003eIn the moment between a worker placing a bucket on the ground and the next picking it up, the line might reposition, in which case the bucket will be left on the ground.\u003c/li\u003e\n\u003cli\u003eOPTIONAL: A small configured number of 'omniworkers' (black) are not part of any team. An omniworker picks up the nearest bucket, fills it at the nearest water source, and dumps it on the nearest fire.\u003c/li\u003e\n\u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Bucket Brigade](_imgs/BucketBrigade.png?raw=true)\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eCombat Bees\u003c/strong\u003e: Two bee hives battle for resources and survival.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n    \n   \u003cul\u003e\n\u003cli\u003eResources (green discs) spawn in the middle. Yellow bees spawn in the yellow base. Blue bees spawn in the blue base.\u003c/li\u003e\n\u003cli\u003eResources spawned at the same location will stack on top of each other.\u003c/li\u003e\n\u003cli\u003eBees pick up resources and drop them in their base.\u003c/li\u003e\n\u003cli\u003eWhen a resource hits the ground of a base, it explodes, spawning several bees of that base's color.\u003c/li\u003e\n\u003cli\u003eBees not carrying resources may attack and destroy enemy bees.\u003c/li\u003e\n\u003cli\u003eA destroyed bee emits bee fragments and blood splatters, and the resource eventually carried falls to the ground.\u003c/li\u003e\n\u003cli\u003eBlood splatters on surfaces shrink to nothing over time.\u003c/li\u003e\n\u003cli\u003eEach bee's displayed scale oscillates along all three axes, but this is just a visual effect. Collisions are not affected.\u003c/li\u003e\n\u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n\u003cli\u003eLeft mouse clicks spawn additional resources at the point clicked (determined by casting a ray from the cursor).\u003c/li\u003e\n\u003cli\u003eThe camera can be controlled with the mouse (hold down right button to rotate, use mouse wheel to zoom). \u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Combat Bees](_imgs/CombatBees.gif?raw=true)\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eHighway Racers\u003c/strong\u003e: Simulate traffic on a 4-lane highway.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n  \n  \u003cul\u003e\n\u003cli\u003eEach car has a random cruising speed, a random overtake speed, a random overtake distance, and a random overtake time (each within a fixed min/max range).\u003c/li\u003e\n\u003cli\u003eWhen traveling at its cruising speed, a car is grey. When going below its cruising speed, it turns red. While going above its cruising speed, it turns green.\u003c/li\u003e\n\u003cli\u003eCars have three main states: cruising, looking to change lane, and overtaking.\u003c/li\u003e\n\u003cli\u003eWhile cruising, a car accelerates/brakes to its cruising speed; if it comes up behind a slower car within its overtake distance, it enters the 'looking to change lane' state.\u003c/li\u003e\n\u003cli\u003eA looking-to-change car will look for sufficient open space to its left or right to change lanes. While blocked from changing lanes, the car will tail the car ahead of it. When it is clear to change lane, it will enter the overtake state.\u003c/li\u003e\n\u003cli\u003eIn the overtake state, a car first moves into another lane, then accelerates to its overtake speed. Once the car's overtake time elapses, it looks to move back into the lane it came from. If blocked from moving back, the car gives up and goes back to the cruising state. If at any time the car is impeded by a slower moving car within its overtake distance, it goes back to the cruising state.\u003c/li\u003e\n\u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Highway Racers](_imgs/HighwayRacers.gif?raw=true)\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eLabRat\u003c/strong\u003e: Place arrows on the board to route the most mice into your home base.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n    \n   \u003cul\u003e\n\u003cli\u003eMice spawn at frequent, randomized intervals from locations randomly chosen at startup.\u003c/li\u003e\n\u003cli\u003eThe board has holes at random locations, both mice and cats can fall into those holes and despawn when that happens.\u003c/li\u003e\n\u003cli\u003eAt start of play, walls are randomly placed between grid cells.\u003c/li\u003e\n\u003cli\u003eCats and mice travel on the grid, changing direction when they hit a wall or travel over an arrow.\u003c/li\u003e\n\u003cli\u003eCats spawn in random squares. When a cat and mouse intersect, the mouse is eaten.\u003c/li\u003e\n\u003cli\u003eWhen a mouse hits a player's 'home base' (one of the four dots placed near the center of the grid), the mouse disappears, and the player is awarded a point.\u003c/li\u003e\n\u003cli\u003eSimilarly, when a cat hits a player's 'home base', the cat disappears, and the player gets negative points.\u003c/li\u003e\n\u003cli\u003ePlayers can place arrows in cells of the board. The green player places green arrows, the red player places red arrows, etc. A player cannot place their arrows in a cell occupied by an arrow of another player.\u003c/li\u003e\n\u003cli\u003eOnce a player has three arrows on the board, their next placed arrow removes their oldest arrow on the board.\u003c/li\u003e\n\u003cli\u003eOnly one player is human. The AI players just place their arrows randomly at random intervals.\u003c/li\u003e\n\u003cli\u003eAt the end of 30 seconds, the player with the most points wins.\u003c/li\u003e\n\u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n\u003cli\u003eWalls can be added at runtime by left clicking while holding the shift key down.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Lab Rat](_imgs/LabRat.gif?raw=true)\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eStack Interchange\u003c/strong\u003e: Cars drive through a stack interchange.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n   \n   \u003cul\u003e\n   \u003cli\u003eAt random intervals, cars spawn at the edge of the straight roads. Cars despawn when they run off the edge of the straight roads.\u003c/li\u003e\n   \u003cli\u003eCars merging onto a new road should yield for cars on the road.\u003c/li\u003e\n   \u003cli\u003eEach road has two lanes. Cars in both lanes of a road travel in the same direction.\u003c/li\u003e\n   \u003cli\u003eCars stay in their lanes through their whole trip, \u003cem\u003ee.g.\u003c/em\u003e a car in the left lane will travel in the left lane on all roads.\u003c/li\u003e\n   \u003cli\u003eEach car has a color matching one of the roadways. A car's path through the interchange must include the roadway maching its color.\u003c/li\u003e\n   \u003cli\u003eSome roadways arch upwards to pass over other roads.\u003c/li\u003e\n   \u003cli\u003eThe simulation has multiple interchanges, but each is unconnected and independent from the others. Cars of one interchange do not travel to the other interchanges.\u003c/li\u003e\n   \u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Stack Interchange](_imgs/StackInterchange.png?raw=true)\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eThrower Arms\u003c/strong\u003e: Mechanical arms throw rocks at tin cans.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n   \n   \u003cul\u003e\n   \u003cli\u003eThe arms and hands are animated by inverse kinematics.\u003c/li\u003e\n   \u003cli\u003eThe cans scroll in from the sides and wrap around.\u003c/li\u003e\n   \u003cli\u003eRocks scroll in from the side and get destroyed once they reach the end. Additional rocks spawn along the path to ensure all arms have sufficient rocks.\u003c/li\u003e\n   \u003cli\u003eTwo arms should never reach for the same ball.\u003c/li\u003e\n   \u003cli\u003eAn arm does not collide with rocks or with other arms. The fingers wrap around a rock but do not actually grip the rock. The rock is temporarily attached to the hand.\u003c/li\u003e\n   \u003cli\u003eOnce an arm has picked up a rock, it targets a can and calculates the required throwing trajectory). (No two arms should ever attempt to pick up the same rock or target the same can.)\u003c/li\u003e\n   \u003cli\u003eWhen struck, a can is affected by gravity and the force of the hit. A single rock can hit multiple cans. Rocks are impacted by their collisions with the cans. Cans do not collide with other cans.\u003c/li\u003e\n   \u003cli\u003eFalling rocks and cans despawn when they fall below a certain altitude.\u003c/li\u003e\n   \u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Thrower Arms](_imgs/ThrowerArms.gif?raw=true)\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eMetro\u003c/strong\u003e: Metro train transport commuters from station to station.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n    \n   \u003cul\u003e\n   \u003cli\u003eThe trains move on a fixed schedule. Passengers should not enter or exit the train if they do not have time to get in position before the train moves.\u003c/li\u003e\n   \u003cli\u003eDisembarking passengers randomly pick another train to board.\u003c/li\u003e\n   \u003cli\u003eThe scene contains a set of authored control points that defines splines for the tracks. Some of these control points also define the placement of stations.\u003c/li\u003e\n   \u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Metro](_imgs/Metro.gif?raw=true)\n\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eZombie Maze\u003c/strong\u003e: A circle picks up capsules in a maze infested with zombies.\u003cbr\u003e\u003ci\u003eClick here for details\u003c/i\u003e\u003c/summary\u003e\n  \n   \u003cul\u003e\n   \u003cli\u003eA player (yellow cube) and zombies (green cubes) move along the grid of the board.\u003c/li\u003e\n   \u003cli\u003eThe interior maze walls are randomly generated at init time.\u003c/li\u003e\n   \u003cli\u003eThe magenta walls move back and forth at a regular interval.\u003c/li\u003e\n   \u003cli\u003eThe player wins by picking up all of the capsules.\u003c/li\u003e\n   \u003cli\u003eMost zombies path towards a randoly chosen pill. When a zombie reaches its destination pill, it selects another pill target.\u003c/li\u003e\n   \u003cli\u003eA fixed number of zombies path towards the player.\u003c/li\u003e\n   \u003cli\u003eKeyboard controls allow the user to reset the simulation.\u003c/li\u003e\n   \u003c/ul\u003e\n\u003c/details\u003e\n\n![Zombie Maze](_imgs/ZombieMaze.png?raw=true)\n\n---\n\n[Deprecated samples](deprecated.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-technologies%2Fdots-training-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funity-technologies%2Fdots-training-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-technologies%2Fdots-training-samples/lists"}