An implementation of boids/flocking for GameObjects.
A sample demoing how to use the Job System + Burst Compiler with traditional GameObjects.
All scenes have a BoidsRunner
GameObject, which will have the appropriate *BoidsRunner
.
For the GameObject version, open up the GameObjectsJobs.unity
scene. This scene
will spawn N GameObjects, where the transforms are written in parallel using the
an IJobParallelForTransform job.
Open up the InstancedJobs.unity
scene. Instead of GameObjects, we open up a buffer of N
matrix elements we want to store and push the data to the Graphics.DrawMeshInstanced
command. This example is a little more advanced than the previous one since we want to
take advantage of pointers and implicit casting for the Mathematics library, which is
Burst friendly.
All jobs are found in the Boids.cs
file. For the jobs used in the InstancedBoidsRunner.cs
,
take a look at the BoidsOnlyPointer.cs
file. Comments have been added where appropriate to
explain the content and how this is set up.
Feel free to use this content if you would like to use it in your projects. (note - per the original author: https://github.com/ThousandAnt/ta-boids)