├── ProjectSettings ├── boot.config ├── ProjectVersion.txt ├── CommonBurstAotSettings.json ├── ClusterInputManager.asset ├── PresetManager.asset ├── XRSettings.asset ├── VersionControlSettings.asset ├── TimeManager.asset ├── EditorBuildSettings.asset ├── VFXManager.asset ├── URPProjectSettings.asset ├── BurstAotSettings_StandaloneWindows.json ├── AudioManager.asset ├── ShaderGraphSettings.asset ├── TagManager.asset ├── UnityConnectSettings.asset ├── PackageManagerSettings.asset ├── MemorySettings.asset ├── DynamicsManager.asset ├── EditorSettings.asset ├── NavMeshAreas.asset ├── Physics2DSettings.asset ├── GraphicsSettings.asset ├── QualitySettings.asset ├── SceneTemplateSettings.json └── InputManager.asset ├── _thumbnails ├── boids-01.png └── boids-02.png ├── Assets ├── Materials │ ├── map-base.png │ ├── map-normal.png │ ├── Shaders.meta │ ├── Ground.mat.meta │ ├── BoidBody.mat.meta │ ├── TestBoid.mat.meta │ ├── BoidDirection.mat.meta │ ├── Shaders │ │ ├── BoidV3 Material.mat.meta │ │ ├── ParallelSimulation.compute.meta │ │ ├── BoidV3 Shader.shadergraph.meta │ │ ├── ParallelSimulation.compute │ │ └── BoidV3 Material.mat │ ├── map-base.png.meta │ ├── map-normal.png.meta │ ├── BoidBody.mat │ ├── Ground.mat │ ├── BoidDirection.mat │ └── TestBoid.mat ├── Prefabs │ ├── Boid.prefab.meta │ ├── BoidV2.prefab.meta │ ├── BoidV3.prefab.meta │ ├── BoidV3.prefab │ ├── Boid.prefab │ └── BoidV2.prefab ├── Editor.meta ├── Prefabs.meta ├── Scenes.meta ├── Scenes │ └── SampleScene.unity.meta ├── Scripts.meta ├── Materials.meta ├── Settings.meta ├── Readme.asset.meta ├── Settings │ ├── URP-Balanced.asset.meta │ ├── URP-HighFidelity.asset.meta │ ├── URP-Performant.asset.meta │ ├── SampleSceneProfile.asset.meta │ ├── URP-Balanced-Renderer.asset.meta │ ├── URP-HighFidelity-Renderer.asset.meta │ ├── URP-Performant-Renderer.asset.meta │ ├── URP-Performant-Renderer.asset │ ├── URP-Performant.asset │ ├── URP-HighFidelity.asset │ ├── URP-Balanced.asset │ ├── URP-Balanced-Renderer.asset │ ├── URP-HighFidelity-Renderer.asset │ └── SampleSceneProfile.asset ├── UniversalRenderPipelineGlobalSettings.asset.meta ├── Scripts │ ├── Boid.cs.meta │ ├── Debug.cs.meta │ ├── Simulation.cs.meta │ ├── TestBoid.cs.meta │ ├── TestPrismMesh.cs.meta │ ├── TestPrismMesh2.cs.meta │ ├── TestSimulation.cs.meta │ ├── RangeWithStepDrawer.cs.meta │ ├── RangeWithStepAttribute.cs.meta │ ├── SceneViewCameraController.cs.meta │ ├── TestSimulation.cs │ ├── RangeWithStepAttribute.cs │ ├── TestPrismMesh.cs │ ├── RangeWithStepDrawer.cs │ ├── TestPrismMesh2.cs │ ├── Debug.cs │ ├── SceneViewCameraController.cs │ ├── TestBoid.cs │ ├── Simulation.cs │ └── Boid.cs ├── Editor │ ├── SimulationEditor.cs.meta │ └── SimulationEditor.cs ├── UniversalRenderPipelineGlobalSettings.asset └── Readme.asset ├── .vscode └── settings.json ├── .gitignore ├── Packages ├── manifest.json └── packages-lock.json ├── README.md └── LICENSE /ProjectSettings/boot.config: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_thumbnails/boids-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuboptimalEng/boids/HEAD/_thumbnails/boids-01.png -------------------------------------------------------------------------------- /_thumbnails/boids-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuboptimalEng/boids/HEAD/_thumbnails/boids-02.png -------------------------------------------------------------------------------- /Assets/Materials/map-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuboptimalEng/boids/HEAD/Assets/Materials/map-base.png -------------------------------------------------------------------------------- /Assets/Materials/map-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuboptimalEng/boids/HEAD/Assets/Materials/map-normal.png -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2021.3.26f1 2 | m_EditorVersionWithRevision: 2021.3.26f1 (a16dc32e0ff2) 3 | -------------------------------------------------------------------------------- /ProjectSettings/CommonBurstAotSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 4, 4 | "DisabledWarnings": "" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /Assets/Prefabs/Boid.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69c384a61ed9a446a93831e34e8e5da4 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /Assets/Prefabs/BoidV2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1f9a65caf7a0462d8b64bee37b9602c 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Prefabs/BoidV3.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75c96cdbece6040a59e1511bd449cccf 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 428cb76b4701d49e789dbec3089c3952 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 425ecbc4231d24b06bf6f986ca136551 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0e31afbb1be0475d87f5420fff657da 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c9720ab356a0642a771bea13969a05 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7a2a1dc6238c49d39638034e5bc2a5c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f13ba8eae12744f42ba2172bc024ac45 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 709f11a7f3c4041caa4ef136ea32d874 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f27e15f4122114b95871811aaca84b27 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Readme.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8105016687592461f977c054a80ce2f2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /Assets/Materials/Ground.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ab3d3e3fb7d44540b0461951289d05a 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Balanced.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1260c1148f6143b28bae5ace5e9c5d1 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials/BoidBody.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cbb3f0d1d8f3467096d3669aa09b693 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials/TestBoid.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a88fa105f6fc0464eaebc65702475c2f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings/URP-HighFidelity.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b7fd9122c28c4d15b667c7040e3b3fd 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Performant.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0e2fc18fe036412f8223b3b3d9ad574 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials/BoidDirection.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16a4d31172fe8405aa2a315e01f87396 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings/SampleSceneProfile.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6560a915ef98420e9faacc1c7438823 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /Assets/Materials/Shaders/BoidV3 Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c3343895f3ecb4870aaa7bb86836e33e 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Balanced-Renderer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e634585d5c4544dd297acaee93dc2beb 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings/URP-HighFidelity-Renderer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c40be3174f62c4acf8c1216858c64956 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Performant-Renderer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 707360a9c581a4bd7aa53bfeb1429f71 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials/Shaders/ParallelSimulation.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 475dcaad4c01a43c3891b28eacaad816 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | preprocessorOverride: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniversalRenderPipelineGlobalSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18dc0cd2c080841dea60987a38ce93fa 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Assets/Scripts/Boid.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 859b42c7ce6344a64b2678b8820167cc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Debug.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e7d5d2959bef4604887977ea8a50faa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Simulation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 738496c3eb2224a05a5df1e49c915a70 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/TestBoid.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f90429ba78ca434fb7a7d0e02ee5963 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Editor/SimulationEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd26594ad9d3b4d97ac47425ccd6834d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/TestPrismMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00f878d2f20264d41921a39e0ed51eb9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/TestPrismMesh2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54d85a9af70f84b71a3801fecc713810 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/TestSimulation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d61487768e8524f1b892e53d5ad4cbbb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/RangeWithStepDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4960706059ea742268f483532a83ef86 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/RangeWithStepAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 622e8b76b6fba45d195c4874ab71fb7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/SceneViewCameraController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a07e7613a7814c01b6e2ceddf5008bd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /Assets/Scripts/TestSimulation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TestSimulation : MonoBehaviour 6 | { 7 | public GameObject boidPrefab; 8 | 9 | void Start() 10 | { 11 | Instantiate(boidPrefab, transform.position + Vector3.up * 0.5f, Quaternion.identity); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Assets/Materials/Shaders/BoidV3 Shader.shadergraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfd95da90e2af4fd48a5a857b7118745 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} 11 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /Assets/Scripts/RangeWithStepAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | // code by chatGPT 6 | public class RangeWithStepAttribute : PropertyAttribute 7 | { 8 | public float min; 9 | public float max; 10 | public float step; 11 | 12 | public RangeWithStepAttribute(float min, float max, float step) 13 | { 14 | this.min = min; 15 | this.max = max; 16 | this.step = step; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ProjectSettings/URPProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 247994e1f5a72c2419c26a37e9334c01, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_LastMaterialVersion: 5 16 | -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneWindows.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 4, 4 | "EnableBurstCompilation": true, 5 | "EnableOptimisations": true, 6 | "EnableSafetyChecks": false, 7 | "EnableDebugInAllBuilds": false, 8 | "UsePlatformSDKLinker": false, 9 | "CpuMinTargetX32": 0, 10 | "CpuMaxTargetX32": 0, 11 | "CpuMinTargetX64": 0, 12 | "CpuMaxTargetX64": 0, 13 | "CpuTargetsX32": 6, 14 | "CpuTargetsX64": 72, 15 | "OptimizeFor": 0 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 0 20 | -------------------------------------------------------------------------------- /ProjectSettings/ShaderGraphSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | customInterpolatorErrorThreshold: 32 16 | customInterpolatorWarningThreshold: 16 17 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - Obstacle 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Assets/Editor/SimulationEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | [CustomEditor(typeof(Simulation))] 7 | public class SimulationEditor : Editor 8 | { 9 | Simulation simulation; 10 | 11 | public override void OnInspectorGUI() 12 | { 13 | using (var check = new EditorGUI.ChangeCheckScope()) 14 | { 15 | base.OnInspectorGUI(); 16 | 17 | if (check.changed) 18 | { 19 | simulation.UpdateBoidSettings(); 20 | } 21 | } 22 | } 23 | 24 | void OnEnable() 25 | { 26 | simulation = target as Simulation; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/UniversalRenderPipelineGlobalSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3} 13 | m_Name: UniversalRenderPipelineGlobalSettings 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 2 16 | lightLayerName0: Light Layer default 17 | lightLayerName1: Light Layer 1 18 | lightLayerName2: Light Layer 2 19 | lightLayerName3: Light Layer 3 20 | lightLayerName4: Light Layer 4 21 | lightLayerName5: Light Layer 5 22 | lightLayerName6: Light Layer 6 23 | lightLayerName7: Light Layer 7 24 | m_StripDebugVariants: 1 25 | m_StripUnusedPostProcessingVariants: 1 26 | m_StripUnusedVariants: 1 27 | supportRuntimeDebugDisplay: 0 28 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | m_PackageRequiringCoreStatsPresent: 0 27 | UnityAdsSettings: 28 | m_Enabled: 0 29 | m_InitializeOnStartup: 1 30 | m_TestMode: 0 31 | m_IosGameId: 32 | m_AndroidGameId: 33 | m_GameIds: {} 34 | m_GameId: 35 | PerformanceReportingSettings: 36 | m_Enabled: 0 37 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /Assets/Readme.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: fcf7219bab7fe46a1ad266029b2fee19, type: 3} 13 | m_Name: Readme 14 | m_EditorClassIdentifier: 15 | icon: {fileID: 2800000, guid: 727a75301c3d24613a3ebcec4a24c2c8, type: 3} 16 | title: URP Empty Template 17 | sections: 18 | - heading: Welcome to the Universal Render Pipeline 19 | text: This template includes the settings and assets you need to start creating with the Universal Render Pipeline. 20 | linkText: 21 | url: 22 | - heading: URP Documentation 23 | text: 24 | linkText: Read more about URP 25 | url: https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest 26 | - heading: Forums 27 | text: 28 | linkText: Get answers and support 29 | url: https://forum.unity.com/forums/universal-render-pipeline.383/ 30 | - heading: Report bugs 31 | text: 32 | linkText: Submit a report 33 | url: https://unity3d.com/unity/qa/bug-reporting 34 | loadedLayout: 1 35 | -------------------------------------------------------------------------------- /Assets/Scripts/TestPrismMesh.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] 6 | public class TestPrismMesh : MonoBehaviour 7 | { 8 | void Start() { } 9 | 10 | void Update() { } 11 | 12 | void OnEnable() 13 | { 14 | Mesh mesh = new Mesh { name = "Procedural Mesh" }; 15 | mesh.vertices = new Vector3[] 16 | { 17 | Vector3.zero, 18 | Vector3.right, 19 | Vector3.up, 20 | new Vector3(1f, 1f) 21 | }; 22 | // back face 23 | // mesh.triangles = new int[] { 0, 1, 2 }; 24 | 25 | // front face 26 | mesh.triangles = new int[] { 0, 2, 1, 1, 2, 3 }; 27 | mesh.normals = new Vector3[] { Vector3.back, Vector3.back, Vector3.back, Vector3.back }; 28 | mesh.uv = new Vector2[] { Vector2.zero, Vector2.right, Vector2.up, Vector2.one }; 29 | 30 | // tangents are incorrect so we must fix them 31 | mesh.tangents = new Vector4[] 32 | { 33 | new Vector4(1f, 0f, 0f, -1f), 34 | new Vector4(1f, 0f, 0f, -1f), 35 | new Vector4(1f, 0f, 0f, -1f), 36 | new Vector4(1f, 0f, 0f, -1f) 37 | }; 38 | GetComponent().mesh = mesh; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /Assets/Scripts/RangeWithStepDrawer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | // code by chatGPT 7 | [CustomPropertyDrawer(typeof(RangeWithStepAttribute))] 8 | public class RangeWithStepDrawer : PropertyDrawer 9 | { 10 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 11 | { 12 | RangeWithStepAttribute rangeWithStep = attribute as RangeWithStepAttribute; 13 | float step = rangeWithStep.step; 14 | 15 | if (property.propertyType == SerializedPropertyType.Float) 16 | { 17 | EditorGUI.BeginChangeCheck(); 18 | 19 | float newValue = EditorGUI.Slider( 20 | position, 21 | label, 22 | property.floatValue, 23 | rangeWithStep.min, 24 | rangeWithStep.max 25 | ); 26 | 27 | newValue = Mathf.Round(newValue / step) * step; 28 | if (EditorGUI.EndChangeCheck()) 29 | { 30 | property.floatValue = newValue; 31 | } 32 | } 33 | else 34 | { 35 | EditorGUI.LabelField( 36 | position, 37 | label.text, 38 | "Use RangeWithStep with float properties only." 39 | ); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0.1 18 | m_ClothInterCollisionStiffness: 0.2 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 0 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ClothGravity: {x: 0, y: -9.81, z: 0} 26 | m_ContactPairsMode: 0 27 | m_BroadphaseType: 0 28 | m_WorldBounds: 29 | m_Center: {x: 0, y: 0, z: 0} 30 | m_Extent: {x: 250, y: 250, z: 250} 31 | m_WorldSubdivisions: 8 32 | m_FrictionType: 0 33 | m_EnableEnhancedDeterminism: 0 34 | m_EnableUnifiedHeightmaps: 1 35 | m_SolverType: 0 36 | m_DefaultMaxAngularSpeed: 50 37 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 0 9 | m_DefaultBehaviorMode: 0 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 0 13 | m_SpritePackerPaddingPower: 1 14 | m_Bc7TextureCompressor: 0 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp 20 | m_ProjectGenerationRootNamespace: 21 | m_EnableTextureStreamingInEditMode: 1 22 | m_EnableTextureStreamingInPlayMode: 1 23 | m_AsyncShaderCompilation: 1 24 | m_CachingShaderPreprocessor: 1 25 | m_PrefabModeAllowAutoSave: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_GameObjectNamingDigits: 1 29 | m_GameObjectNamingScheme: 0 30 | m_AssetNamingUsesSpace: 1 31 | m_UseLegacyProbeSampleCount: 0 32 | m_SerializeInlineMappingsOnOneLine: 0 33 | m_DisableCookiesInLightmapper: 1 34 | m_AssetPipelineMode: 1 35 | m_RefreshImportMode: 0 36 | m_CacheServerMode: 0 37 | m_CacheServerEndpoint: 38 | m_CacheServerNamespacePrefix: default 39 | m_CacheServerEnableDownload: 1 40 | m_CacheServerEnableUpload: 1 41 | m_CacheServerEnableAuth: 0 42 | m_CacheServerEnableTls: 0 43 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": 3 | { 4 | "**/.DS_Store":true, 5 | "**/.git":true, 6 | "**/.gitmodules":true, 7 | "**/*.booproj":true, 8 | "**/*.pidb":true, 9 | "**/*.suo":true, 10 | "**/*.user":true, 11 | "**/*.userprefs":true, 12 | "**/*.unityproj":true, 13 | "**/*.dll":true, 14 | "**/*.exe":true, 15 | "**/*.pdf":true, 16 | "**/*.mid":true, 17 | "**/*.midi":true, 18 | "**/*.wav":true, 19 | "**/*.gif":true, 20 | "**/*.ico":true, 21 | "**/*.jpg":true, 22 | "**/*.jpeg":true, 23 | "**/*.png":true, 24 | "**/*.psd":true, 25 | "**/*.tga":true, 26 | "**/*.tif":true, 27 | "**/*.tiff":true, 28 | "**/*.3ds":true, 29 | "**/*.3DS":true, 30 | "**/*.fbx":true, 31 | "**/*.FBX":true, 32 | "**/*.lxo":true, 33 | "**/*.LXO":true, 34 | "**/*.ma":true, 35 | "**/*.MA":true, 36 | "**/*.obj":true, 37 | "**/*.OBJ":true, 38 | "**/*.asset":true, 39 | "**/*.cubemap":true, 40 | "**/*.flare":true, 41 | "**/*.mat":true, 42 | "**/*.meta":true, 43 | "**/*.prefab":true, 44 | "**/*.unity":true, 45 | "build/":true, 46 | "Build/":true, 47 | "Library/":true, 48 | "library/":true, 49 | "obj/":true, 50 | "Obj/":true, 51 | "ProjectSettings/":true, 52 | "temp/":true, 53 | "Temp/":true 54 | } 55 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | 74 | # MacOS 75 | .DS_Store 76 | **/.DS_Store 77 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /Assets/Scripts/TestPrismMesh2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] 6 | public class TestPrismMesh2 : MonoBehaviour 7 | { 8 | void OnEnable() 9 | { 10 | Mesh mesh = new Mesh { name = "Procedural Mesh" }; 11 | float prismHeight = 0.25f; 12 | mesh.vertices = new Vector3[] 13 | { 14 | new Vector3(0, prismHeight, 0), 15 | new Vector3(1, prismHeight, 0), 16 | new Vector3(0.5f, prismHeight, 1), 17 | new Vector3(0, 0, 0), 18 | new Vector3(1, 0, 0), 19 | new Vector3(0.5f, 0, 1), 20 | }; 21 | mesh.triangles = new int[] 22 | { 23 | // first 24 | 0, 25 | 2, 26 | 1, 27 | // second 28 | 3, 29 | 0, 30 | 4, 31 | // third 32 | 4, 33 | 0, 34 | 1, 35 | // fourth 36 | 4, 37 | 1, 38 | 5, 39 | // fifth 40 | 5, 41 | 1, 42 | 2, 43 | // sixth 44 | 5, 45 | 2, 46 | 3, 47 | // seventh 48 | 3, 49 | 2, 50 | 0 51 | }; 52 | mesh.normals = new Vector3[] 53 | { 54 | Vector3.up, 55 | Vector3.up, 56 | Vector3.up, 57 | Vector3.up, 58 | Vector3.up, 59 | Vector3.up, 60 | }; 61 | // mesh.uv = new Vector2[] { Vector2.zero, Vector2.right, Vector2.up, Vector2.one }; 62 | // mesh.tangents = new Vector4[] 63 | // { 64 | // new Vector4(1f, 0f, 0f, -1f), 65 | // new Vector4(1f, 0f, 0f, -1f), 66 | // new Vector4(1f, 0f, 0f, -1f), 67 | // }; 68 | GetComponent().mesh = mesh; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "2.0.4", 4 | "com.unity.ide.rider": "3.0.21", 5 | "com.unity.ide.visualstudio": "2.0.18", 6 | "com.unity.ide.vscode": "1.2.5", 7 | "com.unity.render-pipelines.universal": "12.1.11", 8 | "com.unity.test-framework": "1.1.33", 9 | "com.unity.textmeshpro": "3.0.6", 10 | "com.unity.timeline": "1.6.5", 11 | "com.unity.ugui": "1.0.0", 12 | "com.unity.visualscripting": "1.8.0", 13 | "com.unity.modules.ai": "1.0.0", 14 | "com.unity.modules.androidjni": "1.0.0", 15 | "com.unity.modules.animation": "1.0.0", 16 | "com.unity.modules.assetbundle": "1.0.0", 17 | "com.unity.modules.audio": "1.0.0", 18 | "com.unity.modules.cloth": "1.0.0", 19 | "com.unity.modules.director": "1.0.0", 20 | "com.unity.modules.imageconversion": "1.0.0", 21 | "com.unity.modules.imgui": "1.0.0", 22 | "com.unity.modules.jsonserialize": "1.0.0", 23 | "com.unity.modules.particlesystem": "1.0.0", 24 | "com.unity.modules.physics": "1.0.0", 25 | "com.unity.modules.physics2d": "1.0.0", 26 | "com.unity.modules.screencapture": "1.0.0", 27 | "com.unity.modules.terrain": "1.0.0", 28 | "com.unity.modules.terrainphysics": "1.0.0", 29 | "com.unity.modules.tilemap": "1.0.0", 30 | "com.unity.modules.ui": "1.0.0", 31 | "com.unity.modules.uielements": "1.0.0", 32 | "com.unity.modules.umbra": "1.0.0", 33 | "com.unity.modules.unityanalytics": "1.0.0", 34 | "com.unity.modules.unitywebrequest": "1.0.0", 35 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 36 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 37 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 38 | "com.unity.modules.unitywebrequestwww": "1.0.0", 39 | "com.unity.modules.vehicles": "1.0.0", 40 | "com.unity.modules.video": "1.0.0", 41 | "com.unity.modules.vr": "1.0.0", 42 | "com.unity.modules.wind": "1.0.0", 43 | "com.unity.modules.xr": "1.0.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Assets/Scripts/Debug.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | // reference by david zulic 6 | // https://medium.com/@davidzulic/unity-drawing-custom-debug-shapes-part-1-4941d3fda905 7 | public class Debug : UnityEngine.Debug 8 | { 9 | public static void DrawCircle(Vector3 position, float radius, int segments, Color color) 10 | { 11 | // If either radius or number of segments are less or equal to 0, skip drawing 12 | if (radius <= 0.0f || segments <= 3) 13 | { 14 | return; 15 | } 16 | 17 | // Single segment of the circle covers (360 / number of segments) degrees 18 | float angleStep = (360.0f / segments); 19 | 20 | // Result is multiplied by Mathf.Deg2Rad constant which transforms degrees to radians 21 | // which are required by Unity's Mathf class trigonometry methods 22 | 23 | angleStep *= Mathf.Deg2Rad; 24 | 25 | // lineStart and lineEnd variables are declared outside of the following for loop 26 | Vector3 lineStart = Vector3.zero; 27 | Vector3 lineEnd = Vector3.zero; 28 | 29 | for (int i = 0; i < segments; i++) 30 | { 31 | // Line start is defined as starting angle of the current segment (i) 32 | lineStart.x = Mathf.Cos(angleStep * i); 33 | lineStart.z = Mathf.Sin(angleStep * i); 34 | 35 | // Line end is defined by the angle of the next segment (i+1) 36 | lineEnd.x = Mathf.Cos(angleStep * (i + 1)); 37 | lineEnd.z = Mathf.Sin(angleStep * (i + 1)); 38 | 39 | // Results are multiplied so they match the desired radius 40 | lineStart *= radius; 41 | lineEnd *= radius; 42 | 43 | // Results are offset by the desired position/origin 44 | lineStart += position; 45 | lineEnd += position; 46 | 47 | // Points are connected using DrawLine method and using the passed color 48 | DrawLine(lineStart, lineEnd, color); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 0 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Performant-Renderer.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} 13 | m_Name: URP-Performant-Renderer 14 | m_EditorClassIdentifier: 15 | debugShaders: 16 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, 17 | type: 3} 18 | m_RendererFeatures: [] 19 | m_RendererFeatureMap: 20 | m_UseNativeRenderPass: 0 21 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} 22 | shaders: 23 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} 24 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} 25 | screenSpaceShadowPS: {fileID: 0} 26 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} 27 | stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3} 28 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} 29 | materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3} 30 | coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3} 31 | coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, 32 | type: 3} 33 | cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, 34 | type: 3} 35 | objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486, 36 | type: 3} 37 | m_AssetVersion: 1 38 | m_OpaqueLayerMask: 39 | serializedVersion: 2 40 | m_Bits: 4294967295 41 | m_TransparentLayerMask: 42 | serializedVersion: 2 43 | m_Bits: 4294967295 44 | m_DefaultStencilState: 45 | overrideStencilState: 0 46 | stencilReference: 0 47 | stencilCompareFunction: 8 48 | passOperation: 2 49 | failOperation: 0 50 | zFailOperation: 0 51 | m_ShadowTransparentReceive: 1 52 | m_RenderingMode: 0 53 | m_DepthPrimingMode: 1 54 | m_AccurateGbufferNormals: 0 55 | m_ClusteredRendering: 0 56 | m_TileSize: 32 57 | m_IntermediateTextureMode: 0 58 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Performant.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: URP-Performant 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 9 16 | k_AssetPreviousVersion: 9 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: 707360a9c581a4bd7aa53bfeb1429f71, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 0 23 | m_RequireOpaqueTexture: 0 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_StoreActionsOptimization: 0 27 | m_SupportsHDR: 0 28 | m_MSAA: 1 29 | m_RenderScale: 1 30 | m_MainLightRenderingMode: 1 31 | m_MainLightShadowsSupported: 0 32 | m_MainLightShadowmapResolution: 1024 33 | m_AdditionalLightsRenderingMode: 0 34 | m_AdditionalLightsPerObjectLimit: 4 35 | m_AdditionalLightShadowsSupported: 0 36 | m_AdditionalLightsShadowmapResolution: 512 37 | m_AdditionalLightsShadowResolutionTierLow: 128 38 | m_AdditionalLightsShadowResolutionTierMedium: 256 39 | m_AdditionalLightsShadowResolutionTierHigh: 512 40 | m_ReflectionProbeBlending: 0 41 | m_ReflectionProbeBoxProjection: 0 42 | m_ShadowDistance: 50 43 | m_ShadowCascadeCount: 1 44 | m_Cascade2Split: 0.25 45 | m_Cascade3Split: {x: 0.1, y: 0.3} 46 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 47 | m_CascadeBorder: 0.1 48 | m_ShadowDepthBias: 1 49 | m_ShadowNormalBias: 1 50 | m_SoftShadowsSupported: 0 51 | m_AdditionalLightsCookieResolution: 2048 52 | m_AdditionalLightsCookieFormat: 3 53 | m_UseSRPBatcher: 1 54 | m_SupportsDynamicBatching: 0 55 | m_MixedLightingSupported: 1 56 | m_SupportsLightLayers: 0 57 | m_DebugLevel: 0 58 | m_UseAdaptivePerformance: 1 59 | m_ColorGradingMode: 0 60 | m_ColorGradingLutSize: 16 61 | m_UseFastSRGBLinearConversion: 0 62 | m_ShadowType: 1 63 | m_LocalShadowsSupported: 0 64 | m_LocalShadowsAtlasResolution: 256 65 | m_MaxPixelLights: 0 66 | m_ShadowAtlasResolution: 256 67 | m_ShaderVariantLogLevel: 0 68 | m_VolumeFrameworkUpdateMode: 0 69 | m_ShadowCascades: 0 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🐟 Boids 2 | 3 | Boids is an algorithm developed by Craig Reynolds in 1986. It aims to emulate the flocking behavior of birds by applying three simple rules: separation, alignment, and cohesion. 4 | 5 | - YouTube Video: [Coding Boids (Flocking Simulation)](https://www.youtube.com/watch?v=MSZ7nqqgVKc) 6 | 7 | 8 | 9 | ## Notes 10 | 11 | - completed: 12 | - separation, alignment, cohesion for boid simulation 13 | - script for updating simulation settings live 14 | - debug view to show show range of each phase 15 | - color picker and randomizer for each boid 16 | - custom attribute `RangeWithStep` for floats 17 | - script to allow camera movement in play mode 18 | - multiple boid prefabs (sphere, cube, triangle shader) 19 | - implement simulation algorithm in a compute shader 20 | - research: 21 | - interactable grass 22 | - simulating boids in 3D 23 | - adding a trail for each boid 24 | - grouping boids based on coloring 25 | - how to create a debug view in shader 26 | - following objects and avoiding edges 27 | - partitioning system for boid detection 28 | - visualizing all boids in a single shader 29 | - normalizing separation + alignment for a more accurate simulation 30 | 31 | ## Resources 32 | 33 | - [Boids by Craig Reynolds](https://www.red3d.com/cwr/boids/) 34 | - [Ben Eater's Boids Simulation](https://eater.net/boids) 35 | - [Daniel Shiffman's Boids Simulation](https://processing.org/examples/flocking.html) 36 | - [Sebastian Lague's Boids Coding Adventure](https://www.youtube.com/watch?v=bqtqltqcQhw) 37 | - [David Zulic's Custom Debug Draw Tutorial for Unity](https://medium.com/@davidzulic/unity-drawing-custom-debug-shapes-part-1-4941d3fda905) 38 | - [Catlike Coding's Creating a Procedural Mesh Tutorial](https://catlikecoding.com/unity/tutorials/procedural-meshes/creating-a-mesh/) 39 | 40 | ## License 41 | 42 | Shield: [![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] 43 | 44 | This work is licensed under a 45 | [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. 46 | 47 | [![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa] 48 | 49 | [cc-by-nc-sa]: http://creativecommons.org/licenses/by-nc-sa/4.0/ 50 | [cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png 51 | [cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg 52 | -------------------------------------------------------------------------------- /Assets/Settings/URP-HighFidelity.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: URP-HighFidelity 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 9 16 | k_AssetPreviousVersion: 9 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: c40be3174f62c4acf8c1216858c64956, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 0 23 | m_RequireOpaqueTexture: 0 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_StoreActionsOptimization: 0 27 | m_SupportsHDR: 1 28 | m_MSAA: 4 29 | m_RenderScale: 1 30 | m_MainLightRenderingMode: 1 31 | m_MainLightShadowsSupported: 1 32 | m_MainLightShadowmapResolution: 4096 33 | m_AdditionalLightsRenderingMode: 1 34 | m_AdditionalLightsPerObjectLimit: 8 35 | m_AdditionalLightShadowsSupported: 1 36 | m_AdditionalLightsShadowmapResolution: 4096 37 | m_AdditionalLightsShadowResolutionTierLow: 128 38 | m_AdditionalLightsShadowResolutionTierMedium: 256 39 | m_AdditionalLightsShadowResolutionTierHigh: 512 40 | m_ReflectionProbeBlending: 1 41 | m_ReflectionProbeBoxProjection: 1 42 | m_ShadowDistance: 150 43 | m_ShadowCascadeCount: 4 44 | m_Cascade2Split: 0.25 45 | m_Cascade3Split: {x: 0.1, y: 0.3} 46 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 47 | m_CascadeBorder: 0.1 48 | m_ShadowDepthBias: 1 49 | m_ShadowNormalBias: 1 50 | m_SoftShadowsSupported: 1 51 | m_AdditionalLightsCookieResolution: 4096 52 | m_AdditionalLightsCookieFormat: 4 53 | m_UseSRPBatcher: 1 54 | m_SupportsDynamicBatching: 0 55 | m_MixedLightingSupported: 1 56 | m_SupportsLightLayers: 0 57 | m_DebugLevel: 0 58 | m_UseAdaptivePerformance: 1 59 | m_ColorGradingMode: 0 60 | m_ColorGradingLutSize: 32 61 | m_UseFastSRGBLinearConversion: 0 62 | m_ShadowType: 1 63 | m_LocalShadowsSupported: 0 64 | m_LocalShadowsAtlasResolution: 256 65 | m_MaxPixelLights: 0 66 | m_ShadowAtlasResolution: 256 67 | m_ShaderVariantLogLevel: 0 68 | m_VolumeFrameworkUpdateMode: 0 69 | m_ShadowCascades: 1 70 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Balanced.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: URP-Balanced 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 9 16 | k_AssetPreviousVersion: 9 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: e634585d5c4544dd297acaee93dc2beb, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 0 23 | m_RequireOpaqueTexture: 0 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_StoreActionsOptimization: 0 27 | m_SupportsHDR: 1 28 | m_MSAA: 1 29 | m_RenderScale: 1 30 | m_UpscalingFilter: 0 31 | m_FsrOverrideSharpness: 0 32 | m_FsrSharpness: 0.92 33 | m_MainLightRenderingMode: 1 34 | m_MainLightShadowsSupported: 1 35 | m_MainLightShadowmapResolution: 1024 36 | m_AdditionalLightsRenderingMode: 1 37 | m_AdditionalLightsPerObjectLimit: 2 38 | m_AdditionalLightShadowsSupported: 0 39 | m_AdditionalLightsShadowmapResolution: 512 40 | m_AdditionalLightsShadowResolutionTierLow: 128 41 | m_AdditionalLightsShadowResolutionTierMedium: 256 42 | m_AdditionalLightsShadowResolutionTierHigh: 512 43 | m_ReflectionProbeBlending: 0 44 | m_ReflectionProbeBoxProjection: 1 45 | m_ShadowDistance: 50 46 | m_ShadowCascadeCount: 1 47 | m_Cascade2Split: 0.25 48 | m_Cascade3Split: {x: 0.1, y: 0.3} 49 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 50 | m_CascadeBorder: 0.1 51 | m_ShadowDepthBias: 1 52 | m_ShadowNormalBias: 1 53 | m_SoftShadowsSupported: 1 54 | m_ConservativeEnclosingSphere: 0 55 | m_NumIterationsEnclosingSphere: 64 56 | m_AdditionalLightsCookieResolution: 512 57 | m_AdditionalLightsCookieFormat: 1 58 | m_UseSRPBatcher: 1 59 | m_SupportsDynamicBatching: 0 60 | m_MixedLightingSupported: 1 61 | m_SupportsLightLayers: 0 62 | m_DebugLevel: 0 63 | m_UseAdaptivePerformance: 1 64 | m_ColorGradingMode: 0 65 | m_ColorGradingLutSize: 32 66 | m_UseFastSRGBLinearConversion: 0 67 | m_ShadowType: 1 68 | m_LocalShadowsSupported: 0 69 | m_LocalShadowsAtlasResolution: 256 70 | m_MaxPixelLights: 0 71 | m_ShadowAtlasResolution: 256 72 | m_ShaderVariantLogLevel: 0 73 | m_VolumeFrameworkUpdateMode: 0 74 | m_ShadowCascades: 0 75 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 14 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_VideoShadersIncludeMode: 2 32 | m_AlwaysIncludedShaders: 33 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 40 | m_PreloadedShaders: [] 41 | m_PreloadShadersBatchTimeLimit: -1 42 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 43 | type: 0} 44 | m_CustomRenderPipeline: {fileID: 11400000, guid: 7b7fd9122c28c4d15b667c7040e3b3fd, 45 | type: 2} 46 | m_TransparencySortMode: 0 47 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 48 | m_DefaultRenderingPath: 1 49 | m_DefaultMobileRenderingPath: 1 50 | m_TierSettings: [] 51 | m_LightmapStripping: 0 52 | m_FogStripping: 0 53 | m_InstancingStripping: 0 54 | m_LightmapKeepPlain: 1 55 | m_LightmapKeepDirCombined: 1 56 | m_LightmapKeepDynamicPlain: 1 57 | m_LightmapKeepDynamicDirCombined: 1 58 | m_LightmapKeepShadowMask: 1 59 | m_LightmapKeepSubtractive: 1 60 | m_FogKeepLinear: 1 61 | m_FogKeepExp: 1 62 | m_FogKeepExp2: 1 63 | m_AlbedoSwatchInfos: [] 64 | m_LightsUseLinearIntensity: 1 65 | m_LightsUseColorTemperature: 1 66 | m_DefaultRenderingLayerMask: 1 67 | m_LogWhenShaderIsCompiled: 0 68 | m_SRPDefaultSettings: 69 | UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: 18dc0cd2c080841dea60987a38ce93fa, 70 | type: 2} 71 | -------------------------------------------------------------------------------- /Assets/Settings/URP-Balanced-Renderer.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-1878332245247344467 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: f62c9c65cf3354c93be831c8bc075510, type: 3} 13 | m_Name: SSAO 14 | m_EditorClassIdentifier: 15 | m_Active: 1 16 | m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3} 17 | m_Settings: 18 | Downsample: 1 19 | AfterOpaque: 0 20 | Source: 0 21 | NormalSamples: 0 22 | Intensity: 0.5 23 | DirectLightingStrength: 0.25 24 | Radius: 0.25 25 | SampleCount: 4 26 | --- !u!114 &11400000 27 | MonoBehaviour: 28 | m_ObjectHideFlags: 0 29 | m_CorrespondingSourceObject: {fileID: 0} 30 | m_PrefabInstance: {fileID: 0} 31 | m_PrefabAsset: {fileID: 0} 32 | m_GameObject: {fileID: 0} 33 | m_Enabled: 1 34 | m_EditorHideFlags: 0 35 | m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} 36 | m_Name: URP-Balanced-Renderer 37 | m_EditorClassIdentifier: 38 | debugShaders: 39 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, 40 | type: 3} 41 | m_RendererFeatures: 42 | - {fileID: -1878332245247344467} 43 | m_RendererFeatureMap: adc0de57c6d2eee5 44 | m_UseNativeRenderPass: 0 45 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} 46 | shaders: 47 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} 48 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} 49 | screenSpaceShadowPS: {fileID: 0} 50 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} 51 | stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3} 52 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} 53 | materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3} 54 | coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3} 55 | coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, 56 | type: 3} 57 | cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, 58 | type: 3} 59 | objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486, 60 | type: 3} 61 | m_AssetVersion: 1 62 | m_OpaqueLayerMask: 63 | serializedVersion: 2 64 | m_Bits: 4294967295 65 | m_TransparentLayerMask: 66 | serializedVersion: 2 67 | m_Bits: 4294967295 68 | m_DefaultStencilState: 69 | overrideStencilState: 0 70 | stencilReference: 0 71 | stencilCompareFunction: 8 72 | passOperation: 2 73 | failOperation: 0 74 | zFailOperation: 0 75 | m_ShadowTransparentReceive: 1 76 | m_RenderingMode: 0 77 | m_DepthPrimingMode: 1 78 | m_AccurateGbufferNormals: 0 79 | m_ClusteredRendering: 0 80 | m_TileSize: 32 81 | m_IntermediateTextureMode: 0 82 | -------------------------------------------------------------------------------- /Assets/Settings/URP-HighFidelity-Renderer.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-1878332245247344467 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: f62c9c65cf3354c93be831c8bc075510, type: 3} 13 | m_Name: SSAO 14 | m_EditorClassIdentifier: 15 | m_Active: 1 16 | m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3} 17 | m_Settings: 18 | Downsample: 0 19 | AfterOpaque: 0 20 | Source: 1 21 | NormalSamples: 1 22 | Intensity: 0.5 23 | DirectLightingStrength: 0.25 24 | Radius: 0.25 25 | SampleCount: 12 26 | --- !u!114 &11400000 27 | MonoBehaviour: 28 | m_ObjectHideFlags: 0 29 | m_CorrespondingSourceObject: {fileID: 0} 30 | m_PrefabInstance: {fileID: 0} 31 | m_PrefabAsset: {fileID: 0} 32 | m_GameObject: {fileID: 0} 33 | m_Enabled: 1 34 | m_EditorHideFlags: 0 35 | m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} 36 | m_Name: URP-HighFidelity-Renderer 37 | m_EditorClassIdentifier: 38 | debugShaders: 39 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, 40 | type: 3} 41 | m_RendererFeatures: 42 | - {fileID: -1878332245247344467} 43 | m_RendererFeatureMap: adc0de57c6d2eee5 44 | m_UseNativeRenderPass: 0 45 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} 46 | shaders: 47 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} 48 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} 49 | screenSpaceShadowPS: {fileID: 0} 50 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} 51 | stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3} 52 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} 53 | materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3} 54 | coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3} 55 | coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, 56 | type: 3} 57 | cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, 58 | type: 3} 59 | objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486, 60 | type: 3} 61 | m_AssetVersion: 1 62 | m_OpaqueLayerMask: 63 | serializedVersion: 2 64 | m_Bits: 4294967295 65 | m_TransparentLayerMask: 66 | serializedVersion: 2 67 | m_Bits: 4294967295 68 | m_DefaultStencilState: 69 | overrideStencilState: 0 70 | stencilReference: 0 71 | stencilCompareFunction: 8 72 | passOperation: 2 73 | failOperation: 0 74 | zFailOperation: 0 75 | m_ShadowTransparentReceive: 1 76 | m_RenderingMode: 0 77 | m_DepthPrimingMode: 1 78 | m_AccurateGbufferNormals: 0 79 | m_ClusteredRendering: 0 80 | m_TileSize: 32 81 | m_IntermediateTextureMode: 0 82 | -------------------------------------------------------------------------------- /Assets/Scripts/SceneViewCameraController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SceneViewCameraController : MonoBehaviour 6 | { 7 | [RangeWithStep(0, 0.5f, 0.05f)] 8 | public float dragSpeed; 9 | 10 | [RangeWithStep(1, 5, 1)] 11 | public float rotationSpeed; 12 | 13 | [RangeWithStep(1, 5, 1)] 14 | public float zoomSpeed; 15 | 16 | [RangeWithStep(1, 10, 1)] 17 | public float moveSpeed; 18 | 19 | bool isGrabbing = false; 20 | Vector3 initialMousePosition; 21 | 22 | void Update() 23 | { 24 | // note: uncomment these to enable camera movement in the game scene 25 | 26 | // mouse left-click drag 27 | // HandleCameraDrag(); 28 | 29 | // mouse right-click rotation 30 | // HandleCameraRotation(); 31 | 32 | // scroll wheel zoom 33 | // HandleCameraZoom(); 34 | 35 | // WASD keys movement 36 | // HandleCameraMovement(); 37 | } 38 | 39 | void HandleCameraDrag() 40 | { 41 | if (Input.GetMouseButtonDown(0)) 42 | { 43 | isGrabbing = true; 44 | initialMousePosition = Input.mousePosition; 45 | } 46 | 47 | if (Input.GetMouseButton(0) && isGrabbing) 48 | { 49 | Vector3 currentMousePosition = Input.mousePosition; 50 | Vector3 difference = 51 | (initialMousePosition - currentMousePosition).normalized * dragSpeed; 52 | 53 | transform.Translate(difference); 54 | initialMousePosition = currentMousePosition; 55 | } 56 | 57 | if (Input.GetMouseButtonUp(0)) 58 | { 59 | isGrabbing = false; 60 | } 61 | } 62 | 63 | Vector3 GetGroundIntersectionPoint() 64 | { 65 | RaycastHit hit; 66 | Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); 67 | 68 | if (Physics.Raycast(ray, out hit)) 69 | { 70 | return hit.point; 71 | } 72 | 73 | return Vector3.zero; 74 | } 75 | 76 | void HandleCameraRotation() 77 | { 78 | if (Input.GetMouseButton(1)) 79 | { 80 | float mouseX = Input.GetAxis("Mouse X") * rotationSpeed; 81 | float mouseY = Input.GetAxis("Mouse Y") * rotationSpeed; 82 | 83 | transform.Rotate(Vector3.up, mouseX, Space.World); 84 | transform.Rotate(Vector3.right, -mouseY, Space.Self); 85 | } 86 | } 87 | 88 | void HandleCameraZoom() 89 | { 90 | float scroll = Input.GetAxis("Mouse ScrollWheel"); 91 | transform.Translate(Vector3.forward * scroll * zoomSpeed, Space.Self); 92 | } 93 | 94 | void HandleCameraMovement() 95 | { 96 | float horizontal = Input.GetAxis("Horizontal"); 97 | float vertical = Input.GetAxis("Vertical"); 98 | Vector3 moveDir = new Vector3(horizontal, 0f, vertical); 99 | moveDir.Normalize(); 100 | if (moveDir != Vector3.zero) 101 | { 102 | transform.Translate(moveDir * moveSpeed * Time.deltaTime, Space.World); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Assets/Materials/Shaders/ParallelSimulation.compute: -------------------------------------------------------------------------------- 1 | // Each #kernel tells which function to compile; you can have many kernels 2 | #pragma kernel CSMain 3 | 4 | struct BoidCompute 5 | { 6 | float3 velocity; 7 | float3 position; 8 | float3 separationVelocity; 9 | float3 alignmentVelocity; 10 | float3 cohesionVelocity; 11 | }; 12 | 13 | RWStructuredBuffer boids; 14 | 15 | int numberOfBoids; 16 | float separationRange; 17 | float alignmentRange; 18 | float cohesionRange; 19 | float separationFactor; 20 | float alignmentFactor; 21 | float cohesionFactor; 22 | 23 | // Create a RenderTexture with enableRandomWrite flag and set it 24 | // with cs.SetTexture 25 | // RWTexture2D Result; 26 | 27 | [numthreads(128,1,1)] 28 | void CSMain (uint3 id : SV_DispatchThreadID) 29 | { 30 | float3 currBoidPosition = boids[id.x].position; 31 | 32 | // TODO: insert actual code here! 33 | // Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0); 34 | int numOfBoidsToAvoid = 0; 35 | int numOfBoidsToAlignWith = 0; 36 | int numOfBoidsInFlock = 0; 37 | 38 | // cohesion variable 39 | float3 positionToMoveTowards = float3(0, 0, 0); 40 | 41 | for (int indexB = 0; indexB < numberOfBoids; indexB++) { 42 | if (id.x == indexB) { 43 | continue; 44 | } 45 | 46 | BoidCompute otherBoid = boids[indexB]; 47 | 48 | float3 otherBoidPosition = otherBoid.position; 49 | float dist = distance(currBoidPosition, otherBoidPosition); 50 | 51 | // separation check 52 | if (dist < separationRange) 53 | { 54 | float3 otherBoidToCurrBoid = currBoidPosition - otherBoidPosition; 55 | float3 dirToTravel = normalize(otherBoidToCurrBoid); 56 | dirToTravel /= dist; 57 | boids[id.x].separationVelocity += dirToTravel; 58 | numOfBoidsToAvoid++; 59 | } 60 | 61 | // alignment check 62 | if (dist < alignmentRange) 63 | { 64 | boids[id.x].alignmentVelocity += otherBoid.velocity; 65 | numOfBoidsToAlignWith++; 66 | } 67 | 68 | // cohesion check 69 | if (dist < cohesionRange) 70 | { 71 | // keep track of the positions of all otherBoids that are in 72 | // the currBoid's cohesionRange 73 | positionToMoveTowards += otherBoidPosition; 74 | numOfBoidsInFlock++; 75 | } 76 | 77 | 78 | } 79 | 80 | if (numOfBoidsToAvoid != 0) 81 | { 82 | boids[id.x].separationVelocity /= (float)numOfBoidsToAvoid; 83 | // normalized values look less cool in the simulation 84 | // boids[id.x].separationVelocity = normalize(boids[id.x].separationVelocity); 85 | boids[id.x].separationVelocity *= separationFactor; 86 | } 87 | 88 | if (numOfBoidsToAlignWith != 0) 89 | { 90 | boids[id.x].alignmentVelocity /= (float)numOfBoidsToAlignWith; 91 | // normalized values look less cool in the simulation 92 | // boids[id.x].alignmentVelocity = normalize(boids[id.x].alignmentVelocity); 93 | boids[id.x].alignmentVelocity *= alignmentFactor; 94 | } 95 | 96 | if (numOfBoidsInFlock != 0) 97 | { 98 | positionToMoveTowards /= (float)numOfBoidsInFlock; 99 | float3 cohesionDirection = positionToMoveTowards - currBoidPosition; 100 | cohesionDirection = normalize(cohesionDirection); 101 | boids[id.x].cohesionVelocity = cohesionDirection * cohesionFactor; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Assets/Materials/map-base.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4fa9b30e00814c4a957e63d3be1ab2a 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 12 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | ignoreMasterTextureLimit: 0 28 | grayScaleToAlpha: 0 29 | generateCubemap: 6 30 | cubemapConvolution: 0 31 | seamlessCubemap: 0 32 | textureFormat: 1 33 | maxTextureSize: 2048 34 | textureSettings: 35 | serializedVersion: 2 36 | filterMode: 1 37 | aniso: 1 38 | mipBias: 0 39 | wrapU: 0 40 | wrapV: 0 41 | wrapW: 0 42 | nPOTScale: 1 43 | lightmap: 0 44 | compressionQuality: 50 45 | spriteMode: 0 46 | spriteExtrude: 1 47 | spriteMeshType: 1 48 | alignment: 0 49 | spritePivot: {x: 0.5, y: 0.5} 50 | spritePixelsToUnits: 100 51 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 52 | spriteGenerateFallbackPhysicsShape: 1 53 | alphaUsage: 1 54 | alphaIsTransparency: 0 55 | spriteTessellationDetail: -1 56 | textureType: 0 57 | textureShape: 1 58 | singleChannelComponent: 0 59 | flipbookRows: 1 60 | flipbookColumns: 1 61 | maxTextureSizeSet: 0 62 | compressionQualitySet: 0 63 | textureFormatSet: 0 64 | ignorePngGamma: 0 65 | applyGammaDecoding: 0 66 | cookieLightType: 0 67 | platformSettings: 68 | - serializedVersion: 3 69 | buildTarget: DefaultTexturePlatform 70 | maxTextureSize: 2048 71 | resizeAlgorithm: 0 72 | textureFormat: -1 73 | textureCompression: 1 74 | compressionQuality: 50 75 | crunchedCompression: 0 76 | allowsAlphaSplitting: 0 77 | overridden: 0 78 | androidETC2FallbackOverride: 0 79 | forceMaximumCompressionQuality_BC6H_BC7: 0 80 | - serializedVersion: 3 81 | buildTarget: Standalone 82 | maxTextureSize: 2048 83 | resizeAlgorithm: 0 84 | textureFormat: -1 85 | textureCompression: 1 86 | compressionQuality: 50 87 | crunchedCompression: 0 88 | allowsAlphaSplitting: 0 89 | overridden: 0 90 | androidETC2FallbackOverride: 0 91 | forceMaximumCompressionQuality_BC6H_BC7: 0 92 | - serializedVersion: 3 93 | buildTarget: Server 94 | maxTextureSize: 2048 95 | resizeAlgorithm: 0 96 | textureFormat: -1 97 | textureCompression: 1 98 | compressionQuality: 50 99 | crunchedCompression: 0 100 | allowsAlphaSplitting: 0 101 | overridden: 0 102 | androidETC2FallbackOverride: 0 103 | forceMaximumCompressionQuality_BC6H_BC7: 0 104 | - serializedVersion: 3 105 | buildTarget: iPhone 106 | maxTextureSize: 2048 107 | resizeAlgorithm: 0 108 | textureFormat: -1 109 | textureCompression: 1 110 | compressionQuality: 50 111 | crunchedCompression: 0 112 | allowsAlphaSplitting: 0 113 | overridden: 0 114 | androidETC2FallbackOverride: 0 115 | forceMaximumCompressionQuality_BC6H_BC7: 0 116 | spriteSheet: 117 | serializedVersion: 2 118 | sprites: [] 119 | outline: [] 120 | physicsShape: [] 121 | bones: [] 122 | spriteID: 123 | internalID: 0 124 | vertices: [] 125 | indices: 126 | edges: [] 127 | weights: [] 128 | secondaryTextures: [] 129 | nameFileIdTable: {} 130 | spritePackingTag: 131 | pSDRemoveMatte: 0 132 | pSDShowRemoveMatteOption: 0 133 | userData: 134 | assetBundleName: 135 | assetBundleVariant: 136 | -------------------------------------------------------------------------------- /Assets/Materials/map-normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01425c71f56544f99be875086c18a6f1 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 12 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 0 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | ignoreMasterTextureLimit: 0 28 | grayScaleToAlpha: 0 29 | generateCubemap: 6 30 | cubemapConvolution: 0 31 | seamlessCubemap: 0 32 | textureFormat: 1 33 | maxTextureSize: 2048 34 | textureSettings: 35 | serializedVersion: 2 36 | filterMode: 1 37 | aniso: 1 38 | mipBias: 0 39 | wrapU: 0 40 | wrapV: 0 41 | wrapW: 0 42 | nPOTScale: 1 43 | lightmap: 0 44 | compressionQuality: 50 45 | spriteMode: 0 46 | spriteExtrude: 1 47 | spriteMeshType: 1 48 | alignment: 0 49 | spritePivot: {x: 0.5, y: 0.5} 50 | spritePixelsToUnits: 100 51 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 52 | spriteGenerateFallbackPhysicsShape: 1 53 | alphaUsage: 1 54 | alphaIsTransparency: 0 55 | spriteTessellationDetail: -1 56 | textureType: 1 57 | textureShape: 1 58 | singleChannelComponent: 0 59 | flipbookRows: 1 60 | flipbookColumns: 1 61 | maxTextureSizeSet: 0 62 | compressionQualitySet: 0 63 | textureFormatSet: 0 64 | ignorePngGamma: 0 65 | applyGammaDecoding: 0 66 | cookieLightType: 0 67 | platformSettings: 68 | - serializedVersion: 3 69 | buildTarget: DefaultTexturePlatform 70 | maxTextureSize: 2048 71 | resizeAlgorithm: 0 72 | textureFormat: -1 73 | textureCompression: 1 74 | compressionQuality: 50 75 | crunchedCompression: 0 76 | allowsAlphaSplitting: 0 77 | overridden: 0 78 | androidETC2FallbackOverride: 0 79 | forceMaximumCompressionQuality_BC6H_BC7: 0 80 | - serializedVersion: 3 81 | buildTarget: Standalone 82 | maxTextureSize: 2048 83 | resizeAlgorithm: 0 84 | textureFormat: -1 85 | textureCompression: 1 86 | compressionQuality: 50 87 | crunchedCompression: 0 88 | allowsAlphaSplitting: 0 89 | overridden: 0 90 | androidETC2FallbackOverride: 0 91 | forceMaximumCompressionQuality_BC6H_BC7: 0 92 | - serializedVersion: 3 93 | buildTarget: Server 94 | maxTextureSize: 2048 95 | resizeAlgorithm: 0 96 | textureFormat: -1 97 | textureCompression: 1 98 | compressionQuality: 50 99 | crunchedCompression: 0 100 | allowsAlphaSplitting: 0 101 | overridden: 0 102 | androidETC2FallbackOverride: 0 103 | forceMaximumCompressionQuality_BC6H_BC7: 0 104 | - serializedVersion: 3 105 | buildTarget: iPhone 106 | maxTextureSize: 2048 107 | resizeAlgorithm: 0 108 | textureFormat: -1 109 | textureCompression: 1 110 | compressionQuality: 50 111 | crunchedCompression: 0 112 | allowsAlphaSplitting: 0 113 | overridden: 0 114 | androidETC2FallbackOverride: 0 115 | forceMaximumCompressionQuality_BC6H_BC7: 0 116 | spriteSheet: 117 | serializedVersion: 2 118 | sprites: [] 119 | outline: [] 120 | physicsShape: [] 121 | bones: [] 122 | spriteID: 123 | internalID: 0 124 | vertices: [] 125 | indices: 126 | edges: [] 127 | weights: [] 128 | secondaryTextures: [] 129 | nameFileIdTable: {} 130 | spritePackingTag: 131 | pSDRemoveMatte: 0 132 | pSDShowRemoveMatteOption: 0 133 | userData: 134 | assetBundleName: 135 | assetBundleVariant: 136 | -------------------------------------------------------------------------------- /Assets/Settings/SampleSceneProfile.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-7893295128165547882 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 3 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3} 13 | m_Name: Bloom 14 | m_EditorClassIdentifier: 15 | active: 0 16 | threshold: 17 | m_OverrideState: 0 18 | m_Value: 1 19 | intensity: 20 | m_OverrideState: 0 21 | m_Value: 1 22 | scatter: 23 | m_OverrideState: 0 24 | m_Value: 0.7 25 | clamp: 26 | m_OverrideState: 0 27 | m_Value: 65472 28 | tint: 29 | m_OverrideState: 0 30 | m_Value: {r: 1, g: 1, b: 1, a: 1} 31 | highQualityFiltering: 32 | m_OverrideState: 0 33 | m_Value: 0 34 | skipIterations: 35 | m_OverrideState: 0 36 | m_Value: 1 37 | dirtTexture: 38 | m_OverrideState: 0 39 | m_Value: {fileID: 0} 40 | dimension: 1 41 | dirtIntensity: 42 | m_OverrideState: 0 43 | m_Value: 0 44 | --- !u!114 &-7011558710299706105 45 | MonoBehaviour: 46 | m_ObjectHideFlags: 3 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInstance: {fileID: 0} 49 | m_PrefabAsset: {fileID: 0} 50 | m_GameObject: {fileID: 0} 51 | m_Enabled: 1 52 | m_EditorHideFlags: 0 53 | m_Script: {fileID: 11500000, guid: 899c54efeace73346a0a16faa3afe726, type: 3} 54 | m_Name: Vignette 55 | m_EditorClassIdentifier: 56 | active: 1 57 | color: 58 | m_OverrideState: 0 59 | m_Value: {r: 0, g: 0, b: 0, a: 1} 60 | center: 61 | m_OverrideState: 0 62 | m_Value: {x: 0.5, y: 0.5} 63 | intensity: 64 | m_OverrideState: 1 65 | m_Value: 0.25 66 | smoothness: 67 | m_OverrideState: 1 68 | m_Value: 0.5 69 | rounded: 70 | m_OverrideState: 0 71 | m_Value: 0 72 | --- !u!114 &-1476876622846166596 73 | MonoBehaviour: 74 | m_ObjectHideFlags: 3 75 | m_CorrespondingSourceObject: {fileID: 0} 76 | m_PrefabInstance: {fileID: 0} 77 | m_PrefabAsset: {fileID: 0} 78 | m_GameObject: {fileID: 0} 79 | m_Enabled: 1 80 | m_EditorHideFlags: 0 81 | m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3} 82 | m_Name: ColorAdjustments 83 | m_EditorClassIdentifier: 84 | active: 1 85 | postExposure: 86 | m_OverrideState: 0 87 | m_Value: 0 88 | contrast: 89 | m_OverrideState: 1 90 | m_Value: 10 91 | colorFilter: 92 | m_OverrideState: 0 93 | m_Value: {r: 1, g: 1, b: 1, a: 1} 94 | hueShift: 95 | m_OverrideState: 0 96 | m_Value: 0 97 | saturation: 98 | m_OverrideState: 0 99 | m_Value: 0 100 | --- !u!114 &11400000 101 | MonoBehaviour: 102 | m_ObjectHideFlags: 0 103 | m_CorrespondingSourceObject: {fileID: 0} 104 | m_PrefabInstance: {fileID: 0} 105 | m_PrefabAsset: {fileID: 0} 106 | m_GameObject: {fileID: 0} 107 | m_Enabled: 1 108 | m_EditorHideFlags: 0 109 | m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} 110 | m_Name: SampleSceneProfile 111 | m_EditorClassIdentifier: 112 | components: 113 | - {fileID: 849379129802519247} 114 | - {fileID: -7893295128165547882} 115 | - {fileID: -7011558710299706105} 116 | - {fileID: -1476876622846166596} 117 | --- !u!114 &849379129802519247 118 | MonoBehaviour: 119 | m_ObjectHideFlags: 3 120 | m_CorrespondingSourceObject: {fileID: 0} 121 | m_PrefabInstance: {fileID: 0} 122 | m_PrefabAsset: {fileID: 0} 123 | m_GameObject: {fileID: 0} 124 | m_Enabled: 1 125 | m_EditorHideFlags: 0 126 | m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3} 127 | m_Name: Tonemapping 128 | m_EditorClassIdentifier: 129 | active: 1 130 | mode: 131 | m_OverrideState: 1 132 | m_Value: 1 133 | -------------------------------------------------------------------------------- /Assets/Materials/BoidBody.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-2844052240659045069 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 5 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 8 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: BoidBody 24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 25 | m_ValidKeywords: [] 26 | m_InvalidKeywords: [] 27 | m_LightmapFlags: 4 28 | m_EnableInstancingVariants: 0 29 | m_DoubleSidedGI: 0 30 | m_CustomRenderQueue: -1 31 | stringTagMap: 32 | RenderType: Opaque 33 | disabledShaderPasses: [] 34 | m_SavedProperties: 35 | serializedVersion: 3 36 | m_TexEnvs: 37 | - _BaseMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _BumpMap: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _DetailAlbedoMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _DetailMask: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _DetailNormalMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | - _EmissionMap: 58 | m_Texture: {fileID: 0} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | - _MainTex: 62 | m_Texture: {fileID: 0} 63 | m_Scale: {x: 1, y: 1} 64 | m_Offset: {x: 0, y: 0} 65 | - _MetallicGlossMap: 66 | m_Texture: {fileID: 0} 67 | m_Scale: {x: 1, y: 1} 68 | m_Offset: {x: 0, y: 0} 69 | - _OcclusionMap: 70 | m_Texture: {fileID: 0} 71 | m_Scale: {x: 1, y: 1} 72 | m_Offset: {x: 0, y: 0} 73 | - _ParallaxMap: 74 | m_Texture: {fileID: 0} 75 | m_Scale: {x: 1, y: 1} 76 | m_Offset: {x: 0, y: 0} 77 | - _SpecGlossMap: 78 | m_Texture: {fileID: 0} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | - unity_Lightmaps: 82 | m_Texture: {fileID: 0} 83 | m_Scale: {x: 1, y: 1} 84 | m_Offset: {x: 0, y: 0} 85 | - unity_LightmapsInd: 86 | m_Texture: {fileID: 0} 87 | m_Scale: {x: 1, y: 1} 88 | m_Offset: {x: 0, y: 0} 89 | - unity_ShadowMasks: 90 | m_Texture: {fileID: 0} 91 | m_Scale: {x: 1, y: 1} 92 | m_Offset: {x: 0, y: 0} 93 | m_Ints: [] 94 | m_Floats: 95 | - _AlphaClip: 0 96 | - _Blend: 0 97 | - _BumpScale: 1 98 | - _ClearCoatMask: 0 99 | - _ClearCoatSmoothness: 0 100 | - _Cull: 2 101 | - _Cutoff: 0.5 102 | - _DetailAlbedoMapScale: 1 103 | - _DetailNormalMapScale: 1 104 | - _DstBlend: 0 105 | - _EnvironmentReflections: 1 106 | - _GlossMapScale: 0 107 | - _Glossiness: 0 108 | - _GlossyReflections: 0 109 | - _Metallic: 0 110 | - _OcclusionStrength: 1 111 | - _Parallax: 0.005 112 | - _QueueOffset: 0 113 | - _ReceiveShadows: 1 114 | - _Smoothness: 0 115 | - _SmoothnessTextureChannel: 0 116 | - _SpecularHighlights: 1 117 | - _SrcBlend: 1 118 | - _Surface: 0 119 | - _WorkflowMode: 1 120 | - _ZWrite: 1 121 | m_Colors: 122 | - _BaseColor: {r: 1, g: 0, b: 0, a: 1} 123 | - _Color: {r: 1, g: 0, b: 0, a: 1} 124 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 125 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} 126 | m_BuildTextureStacks: [] 127 | -------------------------------------------------------------------------------- /Assets/Materials/Ground.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 8 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Ground 11 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 12 | m_ValidKeywords: [] 13 | m_InvalidKeywords: [] 14 | m_LightmapFlags: 4 15 | m_EnableInstancingVariants: 0 16 | m_DoubleSidedGI: 0 17 | m_CustomRenderQueue: -1 18 | stringTagMap: 19 | RenderType: Opaque 20 | disabledShaderPasses: [] 21 | m_SavedProperties: 22 | serializedVersion: 3 23 | m_TexEnvs: 24 | - _BaseMap: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _BumpMap: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | - _DetailAlbedoMap: 33 | m_Texture: {fileID: 0} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _DetailMask: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _DetailNormalMap: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _EmissionMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _MainTex: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _MetallicGlossMap: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | - _OcclusionMap: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | - _ParallaxMap: 61 | m_Texture: {fileID: 0} 62 | m_Scale: {x: 1, y: 1} 63 | m_Offset: {x: 0, y: 0} 64 | - _SpecGlossMap: 65 | m_Texture: {fileID: 0} 66 | m_Scale: {x: 1, y: 1} 67 | m_Offset: {x: 0, y: 0} 68 | - unity_Lightmaps: 69 | m_Texture: {fileID: 0} 70 | m_Scale: {x: 1, y: 1} 71 | m_Offset: {x: 0, y: 0} 72 | - unity_LightmapsInd: 73 | m_Texture: {fileID: 0} 74 | m_Scale: {x: 1, y: 1} 75 | m_Offset: {x: 0, y: 0} 76 | - unity_ShadowMasks: 77 | m_Texture: {fileID: 0} 78 | m_Scale: {x: 1, y: 1} 79 | m_Offset: {x: 0, y: 0} 80 | m_Ints: [] 81 | m_Floats: 82 | - _AlphaClip: 0 83 | - _Blend: 0 84 | - _BumpScale: 1 85 | - _ClearCoatMask: 0 86 | - _ClearCoatSmoothness: 0 87 | - _Cull: 2 88 | - _Cutoff: 0.5 89 | - _DetailAlbedoMapScale: 1 90 | - _DetailNormalMapScale: 1 91 | - _DstBlend: 0 92 | - _EnvironmentReflections: 1 93 | - _GlossMapScale: 0 94 | - _Glossiness: 0 95 | - _GlossyReflections: 0 96 | - _Metallic: 0 97 | - _OcclusionStrength: 1 98 | - _Parallax: 0.005 99 | - _QueueOffset: 0 100 | - _ReceiveShadows: 1 101 | - _Smoothness: 0 102 | - _SmoothnessTextureChannel: 0 103 | - _SpecularHighlights: 1 104 | - _SrcBlend: 1 105 | - _Surface: 0 106 | - _WorkflowMode: 1 107 | - _ZWrite: 1 108 | m_Colors: 109 | - _BaseColor: {r: 0.1981132, g: 0.18409576, b: 0.18409576, a: 1} 110 | - _Color: {r: 0.19811317, g: 0.18409571, b: 0.18409571, a: 1} 111 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 112 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} 113 | m_BuildTextureStacks: [] 114 | --- !u!114 &8421370319089095730 115 | MonoBehaviour: 116 | m_ObjectHideFlags: 11 117 | m_CorrespondingSourceObject: {fileID: 0} 118 | m_PrefabInstance: {fileID: 0} 119 | m_PrefabAsset: {fileID: 0} 120 | m_GameObject: {fileID: 0} 121 | m_Enabled: 1 122 | m_EditorHideFlags: 0 123 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 124 | m_Name: 125 | m_EditorClassIdentifier: 126 | version: 5 127 | -------------------------------------------------------------------------------- /Assets/Materials/BoidDirection.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 8 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: BoidDirection 11 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 12 | m_ValidKeywords: [] 13 | m_InvalidKeywords: [] 14 | m_LightmapFlags: 4 15 | m_EnableInstancingVariants: 0 16 | m_DoubleSidedGI: 0 17 | m_CustomRenderQueue: -1 18 | stringTagMap: 19 | RenderType: Opaque 20 | disabledShaderPasses: [] 21 | m_SavedProperties: 22 | serializedVersion: 3 23 | m_TexEnvs: 24 | - _BaseMap: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _BumpMap: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | - _DetailAlbedoMap: 33 | m_Texture: {fileID: 0} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _DetailMask: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _DetailNormalMap: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _EmissionMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _MainTex: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _MetallicGlossMap: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | - _OcclusionMap: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | - _ParallaxMap: 61 | m_Texture: {fileID: 0} 62 | m_Scale: {x: 1, y: 1} 63 | m_Offset: {x: 0, y: 0} 64 | - _SpecGlossMap: 65 | m_Texture: {fileID: 0} 66 | m_Scale: {x: 1, y: 1} 67 | m_Offset: {x: 0, y: 0} 68 | - unity_Lightmaps: 69 | m_Texture: {fileID: 0} 70 | m_Scale: {x: 1, y: 1} 71 | m_Offset: {x: 0, y: 0} 72 | - unity_LightmapsInd: 73 | m_Texture: {fileID: 0} 74 | m_Scale: {x: 1, y: 1} 75 | m_Offset: {x: 0, y: 0} 76 | - unity_ShadowMasks: 77 | m_Texture: {fileID: 0} 78 | m_Scale: {x: 1, y: 1} 79 | m_Offset: {x: 0, y: 0} 80 | m_Ints: [] 81 | m_Floats: 82 | - _AlphaClip: 0 83 | - _Blend: 0 84 | - _BumpScale: 1 85 | - _ClearCoatMask: 0 86 | - _ClearCoatSmoothness: 0 87 | - _Cull: 2 88 | - _Cutoff: 0.5 89 | - _DetailAlbedoMapScale: 1 90 | - _DetailNormalMapScale: 1 91 | - _DstBlend: 0 92 | - _EnvironmentReflections: 1 93 | - _GlossMapScale: 0 94 | - _Glossiness: 0 95 | - _GlossyReflections: 0 96 | - _Metallic: 0 97 | - _OcclusionStrength: 1 98 | - _Parallax: 0.005 99 | - _QueueOffset: 0 100 | - _ReceiveShadows: 1 101 | - _Smoothness: 0 102 | - _SmoothnessTextureChannel: 0 103 | - _SpecularHighlights: 1 104 | - _SrcBlend: 1 105 | - _Surface: 0 106 | - _WorkflowMode: 1 107 | - _ZWrite: 1 108 | m_Colors: 109 | - _BaseColor: {r: 0.8584906, g: 0.8301442, b: 0.8301442, a: 1} 110 | - _Color: {r: 0.8584906, g: 0.8301442, b: 0.8301442, a: 1} 111 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 112 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} 113 | m_BuildTextureStacks: [] 114 | --- !u!114 &2368333823017767123 115 | MonoBehaviour: 116 | m_ObjectHideFlags: 11 117 | m_CorrespondingSourceObject: {fileID: 0} 118 | m_PrefabInstance: {fileID: 0} 119 | m_PrefabAsset: {fileID: 0} 120 | m_GameObject: {fileID: 0} 121 | m_Enabled: 1 122 | m_EditorHideFlags: 0 123 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 124 | m_Name: 125 | m_EditorClassIdentifier: 126 | version: 5 127 | -------------------------------------------------------------------------------- /Assets/Materials/Shaders/BoidV3 Material.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-4331832755876832032 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 5 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 8 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: BoidV3 Material 24 | m_Shader: {fileID: -6465566751694194690, guid: dfd95da90e2af4fd48a5a857b7118745, 25 | type: 3} 26 | m_ValidKeywords: [] 27 | m_InvalidKeywords: [] 28 | m_LightmapFlags: 4 29 | m_EnableInstancingVariants: 0 30 | m_DoubleSidedGI: 0 31 | m_CustomRenderQueue: -1 32 | stringTagMap: {} 33 | disabledShaderPasses: [] 34 | m_SavedProperties: 35 | serializedVersion: 3 36 | m_TexEnvs: 37 | - _BaseMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _BumpMap: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _DetailAlbedoMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _DetailMask: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _DetailNormalMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | - _EmissionMap: 58 | m_Texture: {fileID: 0} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | - _MainTex: 62 | m_Texture: {fileID: 0} 63 | m_Scale: {x: 1, y: 1} 64 | m_Offset: {x: 0, y: 0} 65 | - _MetallicGlossMap: 66 | m_Texture: {fileID: 0} 67 | m_Scale: {x: 1, y: 1} 68 | m_Offset: {x: 0, y: 0} 69 | - _OcclusionMap: 70 | m_Texture: {fileID: 0} 71 | m_Scale: {x: 1, y: 1} 72 | m_Offset: {x: 0, y: 0} 73 | - _ParallaxMap: 74 | m_Texture: {fileID: 0} 75 | m_Scale: {x: 1, y: 1} 76 | m_Offset: {x: 0, y: 0} 77 | - _SpecGlossMap: 78 | m_Texture: {fileID: 0} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | - unity_Lightmaps: 82 | m_Texture: {fileID: 0} 83 | m_Scale: {x: 1, y: 1} 84 | m_Offset: {x: 0, y: 0} 85 | - unity_LightmapsInd: 86 | m_Texture: {fileID: 0} 87 | m_Scale: {x: 1, y: 1} 88 | m_Offset: {x: 0, y: 0} 89 | - unity_ShadowMasks: 90 | m_Texture: {fileID: 0} 91 | m_Scale: {x: 1, y: 1} 92 | m_Offset: {x: 0, y: 0} 93 | m_Ints: [] 94 | m_Floats: 95 | - _AlphaClip: 0 96 | - _Blend: 0 97 | - _BumpScale: 1 98 | - _ClearCoatMask: 0 99 | - _ClearCoatSmoothness: 0 100 | - _Cull: 2 101 | - _Cutoff: 0.5 102 | - _DetailAlbedoMapScale: 1 103 | - _DetailNormalMapScale: 1 104 | - _DstBlend: 0 105 | - _EnvironmentReflections: 1 106 | - _GlossMapScale: 0 107 | - _Glossiness: 0 108 | - _GlossyReflections: 0 109 | - _Metallic: 0 110 | - _OcclusionStrength: 1 111 | - _Parallax: 0.005 112 | - _QueueControl: 0 113 | - _QueueOffset: 0 114 | - _ReceiveShadows: 1 115 | - _Smoothness: 0.5 116 | - _SmoothnessTextureChannel: 0 117 | - _SpecularHighlights: 1 118 | - _SrcBlend: 1 119 | - _Surface: 0 120 | - _WorkflowMode: 1 121 | - _ZWrite: 1 122 | m_Colors: 123 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 124 | - _BoidColor: {r: 0.49803925, g: 0.49803925, b: 0.49803925, a: 0} 125 | - _BoidColorParam: {r: 0, g: 0, b: 0, a: 0} 126 | - _Color: {r: 1, g: 0, b: 0, a: 1} 127 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 128 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} 129 | m_BuildTextureStacks: [] 130 | -------------------------------------------------------------------------------- /Assets/Materials/TestBoid.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-5308741640836090140 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 5 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 8 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: TestBoid 24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 25 | m_ValidKeywords: 26 | - _NORMALMAP 27 | m_InvalidKeywords: [] 28 | m_LightmapFlags: 4 29 | m_EnableInstancingVariants: 0 30 | m_DoubleSidedGI: 0 31 | m_CustomRenderQueue: -1 32 | stringTagMap: 33 | RenderType: Opaque 34 | disabledShaderPasses: [] 35 | m_SavedProperties: 36 | serializedVersion: 3 37 | m_TexEnvs: 38 | - _BaseMap: 39 | m_Texture: {fileID: 2800000, guid: d4fa9b30e00814c4a957e63d3be1ab2a, type: 3} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _BumpMap: 43 | m_Texture: {fileID: 2800000, guid: 01425c71f56544f99be875086c18a6f1, type: 3} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _DetailAlbedoMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _DetailMask: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _DetailNormalMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | - _EmissionMap: 59 | m_Texture: {fileID: 0} 60 | m_Scale: {x: 1, y: 1} 61 | m_Offset: {x: 0, y: 0} 62 | - _MainTex: 63 | m_Texture: {fileID: 2800000, guid: d4fa9b30e00814c4a957e63d3be1ab2a, type: 3} 64 | m_Scale: {x: 1, y: 1} 65 | m_Offset: {x: 0, y: 0} 66 | - _MetallicGlossMap: 67 | m_Texture: {fileID: 0} 68 | m_Scale: {x: 1, y: 1} 69 | m_Offset: {x: 0, y: 0} 70 | - _OcclusionMap: 71 | m_Texture: {fileID: 0} 72 | m_Scale: {x: 1, y: 1} 73 | m_Offset: {x: 0, y: 0} 74 | - _ParallaxMap: 75 | m_Texture: {fileID: 0} 76 | m_Scale: {x: 1, y: 1} 77 | m_Offset: {x: 0, y: 0} 78 | - _SpecGlossMap: 79 | m_Texture: {fileID: 0} 80 | m_Scale: {x: 1, y: 1} 81 | m_Offset: {x: 0, y: 0} 82 | - unity_Lightmaps: 83 | m_Texture: {fileID: 0} 84 | m_Scale: {x: 1, y: 1} 85 | m_Offset: {x: 0, y: 0} 86 | - unity_LightmapsInd: 87 | m_Texture: {fileID: 0} 88 | m_Scale: {x: 1, y: 1} 89 | m_Offset: {x: 0, y: 0} 90 | - unity_ShadowMasks: 91 | m_Texture: {fileID: 0} 92 | m_Scale: {x: 1, y: 1} 93 | m_Offset: {x: 0, y: 0} 94 | m_Ints: [] 95 | m_Floats: 96 | - _AlphaClip: 0 97 | - _Blend: 0 98 | - _BumpScale: 1 99 | - _ClearCoatMask: 0 100 | - _ClearCoatSmoothness: 0 101 | - _Cull: 2 102 | - _Cutoff: 0.5 103 | - _DetailAlbedoMapScale: 1 104 | - _DetailNormalMapScale: 1 105 | - _DstBlend: 0 106 | - _EnvironmentReflections: 1 107 | - _GlossMapScale: 0 108 | - _Glossiness: 0 109 | - _GlossyReflections: 0 110 | - _Metallic: 0 111 | - _OcclusionStrength: 1 112 | - _Parallax: 0.005 113 | - _QueueOffset: 0 114 | - _ReceiveShadows: 1 115 | - _Smoothness: 0.5 116 | - _SmoothnessTextureChannel: 0 117 | - _SpecularHighlights: 1 118 | - _SrcBlend: 1 119 | - _Surface: 0 120 | - _WorkflowMode: 1 121 | - _ZWrite: 1 122 | m_Colors: 123 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 124 | - _Color: {r: 1, g: 1, b: 1, a: 1} 125 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 126 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} 127 | m_BuildTextureStacks: [] 128 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 2 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Performant 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 20 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | skinWeights: 2 22 | textureQuality: 0 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.4 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | customRenderPipeline: {fileID: 11400000, guid: d0e2fc18fe036412f8223b3b3d9ad574, 44 | type: 2} 45 | excludedTargetPlatforms: [] 46 | - serializedVersion: 2 47 | name: Balanced 48 | pixelLightCount: 1 49 | shadows: 1 50 | shadowResolution: 0 51 | shadowProjection: 1 52 | shadowCascades: 1 53 | shadowDistance: 20 54 | shadowNearPlaneOffset: 3 55 | shadowCascade2Split: 0.33333334 56 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 57 | shadowmaskMode: 0 58 | skinWeights: 4 59 | textureQuality: 0 60 | anisotropicTextures: 1 61 | antiAliasing: 0 62 | softParticles: 0 63 | softVegetation: 0 64 | realtimeReflectionProbes: 0 65 | billboardsFaceCameraPosition: 0 66 | vSyncCount: 1 67 | lodBias: 1 68 | maximumLODLevel: 0 69 | streamingMipmapsActive: 0 70 | streamingMipmapsAddAllCameras: 1 71 | streamingMipmapsMemoryBudget: 512 72 | streamingMipmapsRenderersPerFrame: 512 73 | streamingMipmapsMaxLevelReduction: 2 74 | streamingMipmapsMaxFileIORequests: 1024 75 | particleRaycastBudget: 64 76 | asyncUploadTimeSlice: 2 77 | asyncUploadBufferSize: 16 78 | asyncUploadPersistentBuffer: 1 79 | resolutionScalingFixedDPIFactor: 1 80 | customRenderPipeline: {fileID: 11400000, guid: e1260c1148f6143b28bae5ace5e9c5d1, 81 | type: 2} 82 | excludedTargetPlatforms: [] 83 | - serializedVersion: 2 84 | name: High Fidelity 85 | pixelLightCount: 2 86 | shadows: 2 87 | shadowResolution: 1 88 | shadowProjection: 1 89 | shadowCascades: 2 90 | shadowDistance: 40 91 | shadowNearPlaneOffset: 3 92 | shadowCascade2Split: 0.33333334 93 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 94 | shadowmaskMode: 1 95 | skinWeights: 255 96 | textureQuality: 0 97 | anisotropicTextures: 2 98 | antiAliasing: 4 99 | softParticles: 0 100 | softVegetation: 1 101 | realtimeReflectionProbes: 1 102 | billboardsFaceCameraPosition: 1 103 | vSyncCount: 1 104 | lodBias: 2 105 | maximumLODLevel: 0 106 | streamingMipmapsActive: 0 107 | streamingMipmapsAddAllCameras: 1 108 | streamingMipmapsMemoryBudget: 512 109 | streamingMipmapsRenderersPerFrame: 512 110 | streamingMipmapsMaxLevelReduction: 2 111 | streamingMipmapsMaxFileIORequests: 1024 112 | particleRaycastBudget: 2048 113 | asyncUploadTimeSlice: 2 114 | asyncUploadBufferSize: 16 115 | asyncUploadPersistentBuffer: 1 116 | resolutionScalingFixedDPIFactor: 1 117 | customRenderPipeline: {fileID: 11400000, guid: 7b7fd9122c28c4d15b667c7040e3b3fd, 118 | type: 2} 119 | excludedTargetPlatforms: [] 120 | m_PerPlatformDefaultQuality: 121 | Android: 1 122 | CloudRendering: 2 123 | GameCoreScarlett: 2 124 | GameCoreXboxOne: 2 125 | Lumin: 2 126 | Nintendo Switch: 1 127 | PS4: 2 128 | PS5: 2 129 | Server: 0 130 | Stadia: 2 131 | Standalone: 2 132 | WebGL: 1 133 | Windows Store Apps: 2 134 | XboxOne: 2 135 | iPhone: 1 136 | tvOS: 1 137 | -------------------------------------------------------------------------------- /Assets/Prefabs/BoidV3.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &4308843329111450751 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 2326211221164047253} 12 | - component: {fileID: 8011276635846578174} 13 | - component: {fileID: 4054346765732343043} 14 | m_Layer: 0 15 | m_Name: BoidV3 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &2326211221164047253 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 4308843329111450751} 28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 29 | m_LocalPosition: {x: 0, y: 0.5, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: 1} 31 | m_ConstrainProportionsScale: 0 32 | m_Children: 33 | - {fileID: 7168466754859006766} 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 37 | --- !u!114 &8011276635846578174 38 | MonoBehaviour: 39 | m_ObjectHideFlags: 0 40 | m_CorrespondingSourceObject: {fileID: 0} 41 | m_PrefabInstance: {fileID: 0} 42 | m_PrefabAsset: {fileID: 0} 43 | m_GameObject: {fileID: 4308843329111450751} 44 | m_Enabled: 1 45 | m_EditorHideFlags: 0 46 | m_Script: {fileID: 11500000, guid: 859b42c7ce6344a64b2678b8820167cc, type: 3} 47 | m_Name: 48 | m_EditorClassIdentifier: 49 | velocity: {x: 0, y: 0, z: 0} 50 | --- !u!65 &4054346765732343043 51 | BoxCollider: 52 | m_ObjectHideFlags: 0 53 | m_CorrespondingSourceObject: {fileID: 0} 54 | m_PrefabInstance: {fileID: 0} 55 | m_PrefabAsset: {fileID: 0} 56 | m_GameObject: {fileID: 4308843329111450751} 57 | m_Material: {fileID: 0} 58 | m_IsTrigger: 0 59 | m_Enabled: 1 60 | serializedVersion: 2 61 | m_Size: {x: 1, y: 0.05, z: 1.25} 62 | m_Center: {x: 0, y: 0.5, z: 0} 63 | --- !u!1 &5169994949497747905 64 | GameObject: 65 | m_ObjectHideFlags: 0 66 | m_CorrespondingSourceObject: {fileID: 0} 67 | m_PrefabInstance: {fileID: 0} 68 | m_PrefabAsset: {fileID: 0} 69 | serializedVersion: 6 70 | m_Component: 71 | - component: {fileID: 7168466754859006766} 72 | - component: {fileID: 3498547889459138405} 73 | - component: {fileID: 5419867417327138544} 74 | - component: {fileID: 1233478520446520268} 75 | m_Layer: 0 76 | m_Name: Quad 77 | m_TagString: Untagged 78 | m_Icon: {fileID: 0} 79 | m_NavMeshLayer: 0 80 | m_StaticEditorFlags: 0 81 | m_IsActive: 1 82 | --- !u!4 &7168466754859006766 83 | Transform: 84 | m_ObjectHideFlags: 0 85 | m_CorrespondingSourceObject: {fileID: 0} 86 | m_PrefabInstance: {fileID: 0} 87 | m_PrefabAsset: {fileID: 0} 88 | m_GameObject: {fileID: 5169994949497747905} 89 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 90 | m_LocalPosition: {x: 0, y: 0.5, z: 0} 91 | m_LocalScale: {x: 2, y: 2, z: 2} 92 | m_ConstrainProportionsScale: 0 93 | m_Children: [] 94 | m_Father: {fileID: 2326211221164047253} 95 | m_RootOrder: 0 96 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 97 | --- !u!33 &3498547889459138405 98 | MeshFilter: 99 | m_ObjectHideFlags: 0 100 | m_CorrespondingSourceObject: {fileID: 0} 101 | m_PrefabInstance: {fileID: 0} 102 | m_PrefabAsset: {fileID: 0} 103 | m_GameObject: {fileID: 5169994949497747905} 104 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 105 | --- !u!23 &5419867417327138544 106 | MeshRenderer: 107 | m_ObjectHideFlags: 0 108 | m_CorrespondingSourceObject: {fileID: 0} 109 | m_PrefabInstance: {fileID: 0} 110 | m_PrefabAsset: {fileID: 0} 111 | m_GameObject: {fileID: 5169994949497747905} 112 | m_Enabled: 1 113 | m_CastShadows: 1 114 | m_ReceiveShadows: 1 115 | m_DynamicOccludee: 1 116 | m_StaticShadowCaster: 0 117 | m_MotionVectors: 1 118 | m_LightProbeUsage: 1 119 | m_ReflectionProbeUsage: 1 120 | m_RayTracingMode: 2 121 | m_RayTraceProcedural: 0 122 | m_RenderingLayerMask: 1 123 | m_RendererPriority: 0 124 | m_Materials: 125 | - {fileID: 2100000, guid: c3343895f3ecb4870aaa7bb86836e33e, type: 2} 126 | m_StaticBatchInfo: 127 | firstSubMesh: 0 128 | subMeshCount: 0 129 | m_StaticBatchRoot: {fileID: 0} 130 | m_ProbeAnchor: {fileID: 0} 131 | m_LightProbeVolumeOverride: {fileID: 0} 132 | m_ScaleInLightmap: 1 133 | m_ReceiveGI: 1 134 | m_PreserveUVs: 0 135 | m_IgnoreNormalsForChartDetection: 0 136 | m_ImportantGI: 0 137 | m_StitchLightmapSeams: 1 138 | m_SelectedEditorRenderState: 3 139 | m_MinimumChartSize: 4 140 | m_AutoUVMaxDistance: 0.5 141 | m_AutoUVMaxAngle: 89 142 | m_LightmapParameters: {fileID: 0} 143 | m_SortingLayerID: 0 144 | m_SortingLayer: 0 145 | m_SortingOrder: 0 146 | m_AdditionalVertexStreams: {fileID: 0} 147 | --- !u!64 &1233478520446520268 148 | MeshCollider: 149 | m_ObjectHideFlags: 0 150 | m_CorrespondingSourceObject: {fileID: 0} 151 | m_PrefabInstance: {fileID: 0} 152 | m_PrefabAsset: {fileID: 0} 153 | m_GameObject: {fileID: 5169994949497747905} 154 | m_Material: {fileID: 0} 155 | m_IsTrigger: 0 156 | m_Enabled: 1 157 | serializedVersion: 4 158 | m_Convex: 0 159 | m_CookingOptions: 30 160 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 161 | -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "ignore": false, 8 | "defaultInstantiationMode": 0, 9 | "supportsModification": true 10 | }, 11 | { 12 | "userAdded": false, 13 | "type": "UnityEditor.Animations.AnimatorController", 14 | "ignore": false, 15 | "defaultInstantiationMode": 0, 16 | "supportsModification": true 17 | }, 18 | { 19 | "userAdded": false, 20 | "type": "UnityEngine.AnimatorOverrideController", 21 | "ignore": false, 22 | "defaultInstantiationMode": 0, 23 | "supportsModification": true 24 | }, 25 | { 26 | "userAdded": false, 27 | "type": "UnityEditor.Audio.AudioMixerController", 28 | "ignore": false, 29 | "defaultInstantiationMode": 0, 30 | "supportsModification": true 31 | }, 32 | { 33 | "userAdded": false, 34 | "type": "UnityEngine.ComputeShader", 35 | "ignore": true, 36 | "defaultInstantiationMode": 1, 37 | "supportsModification": true 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEngine.Cubemap", 42 | "ignore": false, 43 | "defaultInstantiationMode": 0, 44 | "supportsModification": true 45 | }, 46 | { 47 | "userAdded": false, 48 | "type": "UnityEngine.GameObject", 49 | "ignore": false, 50 | "defaultInstantiationMode": 0, 51 | "supportsModification": true 52 | }, 53 | { 54 | "userAdded": false, 55 | "type": "UnityEditor.LightingDataAsset", 56 | "ignore": false, 57 | "defaultInstantiationMode": 0, 58 | "supportsModification": false 59 | }, 60 | { 61 | "userAdded": false, 62 | "type": "UnityEngine.LightingSettings", 63 | "ignore": false, 64 | "defaultInstantiationMode": 0, 65 | "supportsModification": true 66 | }, 67 | { 68 | "userAdded": false, 69 | "type": "UnityEngine.Material", 70 | "ignore": false, 71 | "defaultInstantiationMode": 0, 72 | "supportsModification": true 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEditor.MonoScript", 77 | "ignore": true, 78 | "defaultInstantiationMode": 1, 79 | "supportsModification": true 80 | }, 81 | { 82 | "userAdded": false, 83 | "type": "UnityEngine.PhysicMaterial", 84 | "ignore": false, 85 | "defaultInstantiationMode": 0, 86 | "supportsModification": true 87 | }, 88 | { 89 | "userAdded": false, 90 | "type": "UnityEngine.PhysicsMaterial2D", 91 | "ignore": false, 92 | "defaultInstantiationMode": 0, 93 | "supportsModification": true 94 | }, 95 | { 96 | "userAdded": false, 97 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 98 | "ignore": false, 99 | "defaultInstantiationMode": 0, 100 | "supportsModification": true 101 | }, 102 | { 103 | "userAdded": false, 104 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 105 | "ignore": false, 106 | "defaultInstantiationMode": 0, 107 | "supportsModification": true 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Rendering.VolumeProfile", 112 | "ignore": false, 113 | "defaultInstantiationMode": 0, 114 | "supportsModification": true 115 | }, 116 | { 117 | "userAdded": false, 118 | "type": "UnityEditor.SceneAsset", 119 | "ignore": false, 120 | "defaultInstantiationMode": 0, 121 | "supportsModification": false 122 | }, 123 | { 124 | "userAdded": false, 125 | "type": "UnityEngine.Shader", 126 | "ignore": true, 127 | "defaultInstantiationMode": 1, 128 | "supportsModification": true 129 | }, 130 | { 131 | "userAdded": false, 132 | "type": "UnityEngine.ShaderVariantCollection", 133 | "ignore": true, 134 | "defaultInstantiationMode": 1, 135 | "supportsModification": true 136 | }, 137 | { 138 | "userAdded": false, 139 | "type": "UnityEngine.Texture", 140 | "ignore": false, 141 | "defaultInstantiationMode": 0, 142 | "supportsModification": true 143 | }, 144 | { 145 | "userAdded": false, 146 | "type": "UnityEngine.Texture2D", 147 | "ignore": false, 148 | "defaultInstantiationMode": 0, 149 | "supportsModification": true 150 | }, 151 | { 152 | "userAdded": false, 153 | "type": "UnityEngine.Timeline.TimelineAsset", 154 | "ignore": false, 155 | "defaultInstantiationMode": 0, 156 | "supportsModification": true 157 | } 158 | ], 159 | "defaultDependencyTypeInfo": { 160 | "userAdded": false, 161 | "type": "", 162 | "ignore": false, 163 | "defaultInstantiationMode": 1, 164 | "supportsModification": true 165 | }, 166 | "newSceneOverride": 0 167 | } -------------------------------------------------------------------------------- /Assets/Scripts/TestBoid.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TestBoid : MonoBehaviour 6 | { 7 | [Range(1, 4)] 8 | public int movementSpeed; 9 | 10 | [Range(1, 8)] 11 | public int rotationSpeed; 12 | 13 | [Range(1, 4)] 14 | public int lookAheadDist; 15 | 16 | [Range(8, 64)] 17 | public int fovPrecision; 18 | float maxNumOfDegrees; 19 | float fovDegreeIncrement; 20 | 21 | public LayerMask hittableLayerMask; 22 | 23 | bool enableDebugLines; 24 | int fovDirectionIndex; 25 | List fovDirections; 26 | 27 | void Initialize() 28 | { 29 | enableDebugLines = true; 30 | fovDirectionIndex = 0; 31 | maxNumOfDegrees = 360f; 32 | fovDirections = new List(); 33 | 34 | // e.g. precision -> 10, degree increment -> 36 35 | // e.g. precision -> 12, degree increment -> 30 36 | // e.g. precision -> 36, degree increment -> 10 37 | fovDegreeIncrement = maxNumOfDegrees / fovPrecision; 38 | 39 | for (float degrees = 0; degrees < maxNumOfDegrees; degrees += fovDegreeIncrement) 40 | { 41 | Vector3 fovDirection = new Vector3( 42 | Mathf.Cos(degrees * Mathf.Deg2Rad), 43 | 0, 44 | Mathf.Sin(degrees * Mathf.Deg2Rad) 45 | ); 46 | fovDirections.Add(fovDirection); 47 | } 48 | } 49 | 50 | void Move() 51 | { 52 | fovDirectionIndex = GetFovDirectionIndex(); 53 | 54 | // note: decided to use Vector3.Lerp instead of manually setting the position 55 | // transform.position += 56 | // fovDirections[fovDirectionIndex] * movementSpeed * Time.deltaTime * 0.75f; 57 | 58 | Vector3 targetPosition = transform.position + fovDirections[fovDirectionIndex]; 59 | transform.position = Vector3.Lerp( 60 | transform.position, 61 | targetPosition, 62 | movementSpeed * Time.deltaTime 63 | ); 64 | 65 | Quaternion targetRotation = Quaternion.LookRotation(fovDirections[fovDirectionIndex]); 66 | transform.rotation = Quaternion.Lerp( 67 | transform.rotation, 68 | targetRotation, 69 | rotationSpeed * Time.deltaTime 70 | ); 71 | } 72 | 73 | int GetFovDirectionIndex() 74 | { 75 | Vector3 startPosition = transform.position; 76 | 77 | RaycastHit closestHit; 78 | int closestHitIndex = -1; 79 | float closestHitDist = Mathf.Infinity; 80 | 81 | for (int i = 0; i < fovDirections.Count; i++) 82 | { 83 | Vector3 fovDirection = fovDirections[i]; 84 | RaycastHit hit; 85 | if ( 86 | Physics.Raycast( 87 | startPosition, 88 | fovDirection, 89 | out hit, 90 | lookAheadDist, 91 | hittableLayerMask 92 | ) 93 | ) 94 | { 95 | if (hit.distance < closestHitDist) 96 | { 97 | closestHit = hit; 98 | closestHitIndex = i; 99 | closestHitDist = hit.distance; 100 | } 101 | } 102 | } 103 | 104 | if (closestHitIndex < 0 || closestHitDist > lookAheadDist / 2f) 105 | { 106 | return fovDirectionIndex; 107 | } 108 | 109 | Vector3 fovDirAboutToHit = fovDirections[closestHitIndex]; 110 | Vector3 moveAwayDirection = -1 * fovDirAboutToHit; 111 | Vector3 bisectVector = Vector3.Lerp( 112 | moveAwayDirection, 113 | fovDirections[fovDirectionIndex], 114 | 0.5f 115 | ); 116 | 117 | int newFovDirectionIndex = fovDirectionIndex; 118 | for (int i = 0; i < fovDirections.Count; i++) 119 | { 120 | Vector3 fovDirection = fovDirections[i]; 121 | if (Vector3.Angle(fovDirection, bisectVector) < fovDegreeIncrement) 122 | { 123 | newFovDirectionIndex = i; 124 | } 125 | } 126 | 127 | return newFovDirectionIndex; 128 | } 129 | 130 | void Start() 131 | { 132 | Initialize(); 133 | } 134 | 135 | void OnValidate() 136 | { 137 | Initialize(); 138 | } 139 | 140 | void Update() 141 | { 142 | Move(); 143 | 144 | DrawDebugLines(); 145 | } 146 | 147 | public void ToggleDebugLines() 148 | { 149 | enableDebugLines = !enableDebugLines; 150 | } 151 | 152 | void DrawDebugLines() 153 | { 154 | // todo: draw debug lines only when user clicks on a boid 155 | if (!enableDebugLines) 156 | { 157 | return; 158 | } 159 | 160 | Vector3 startPosition = transform.position; 161 | for (int i = 0; i < fovDirections.Count; i++) 162 | { 163 | Vector3 fovDirection = fovDirections[i]; 164 | 165 | RaycastHit hit; 166 | bool raycastHitObstacle = Physics.Raycast( 167 | startPosition, 168 | fovDirection, 169 | out hit, 170 | lookAheadDist, 171 | hittableLayerMask 172 | ); 173 | 174 | bool isCurrFovDir = i == fovDirectionIndex; 175 | 176 | if (raycastHitObstacle) 177 | { 178 | Debug.DrawRay(startPosition, fovDirection * hit.distance, Color.red); 179 | } 180 | else if (isCurrFovDir) 181 | { 182 | Debug.DrawRay(startPosition, fovDirection * lookAheadDist, Color.blue); 183 | } 184 | else 185 | { 186 | Debug.DrawRay(startPosition, fovDirection * lookAheadDist, Color.green); 187 | } 188 | } 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /Assets/Prefabs/Boid.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &2557076483051825545 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 6920116202222419103} 12 | - component: {fileID: 4765929045683736987} 13 | - component: {fileID: 8762460685393991865} 14 | - component: {fileID: 187930910092778795} 15 | m_Layer: 0 16 | m_Name: Body 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &6920116202222419103 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 2557076483051825545} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0.5, z: 0} 31 | m_LocalScale: {x: 1, y: 1, z: 1} 32 | m_ConstrainProportionsScale: 0 33 | m_Children: 34 | - {fileID: 2477297412567272144} 35 | m_Father: {fileID: 2326211221164047253} 36 | m_RootOrder: 0 37 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 38 | --- !u!33 &4765929045683736987 39 | MeshFilter: 40 | m_ObjectHideFlags: 0 41 | m_CorrespondingSourceObject: {fileID: 0} 42 | m_PrefabInstance: {fileID: 0} 43 | m_PrefabAsset: {fileID: 0} 44 | m_GameObject: {fileID: 2557076483051825545} 45 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} 46 | --- !u!23 &8762460685393991865 47 | MeshRenderer: 48 | m_ObjectHideFlags: 0 49 | m_CorrespondingSourceObject: {fileID: 0} 50 | m_PrefabInstance: {fileID: 0} 51 | m_PrefabAsset: {fileID: 0} 52 | m_GameObject: {fileID: 2557076483051825545} 53 | m_Enabled: 1 54 | m_CastShadows: 1 55 | m_ReceiveShadows: 1 56 | m_DynamicOccludee: 1 57 | m_StaticShadowCaster: 0 58 | m_MotionVectors: 1 59 | m_LightProbeUsage: 1 60 | m_ReflectionProbeUsage: 1 61 | m_RayTracingMode: 2 62 | m_RayTraceProcedural: 0 63 | m_RenderingLayerMask: 1 64 | m_RendererPriority: 0 65 | m_Materials: 66 | - {fileID: 2100000, guid: 9cbb3f0d1d8f3467096d3669aa09b693, type: 2} 67 | m_StaticBatchInfo: 68 | firstSubMesh: 0 69 | subMeshCount: 0 70 | m_StaticBatchRoot: {fileID: 0} 71 | m_ProbeAnchor: {fileID: 0} 72 | m_LightProbeVolumeOverride: {fileID: 0} 73 | m_ScaleInLightmap: 1 74 | m_ReceiveGI: 1 75 | m_PreserveUVs: 0 76 | m_IgnoreNormalsForChartDetection: 0 77 | m_ImportantGI: 0 78 | m_StitchLightmapSeams: 1 79 | m_SelectedEditorRenderState: 3 80 | m_MinimumChartSize: 4 81 | m_AutoUVMaxDistance: 0.5 82 | m_AutoUVMaxAngle: 89 83 | m_LightmapParameters: {fileID: 0} 84 | m_SortingLayerID: 0 85 | m_SortingLayer: 0 86 | m_SortingOrder: 0 87 | m_AdditionalVertexStreams: {fileID: 0} 88 | --- !u!135 &187930910092778795 89 | SphereCollider: 90 | m_ObjectHideFlags: 0 91 | m_CorrespondingSourceObject: {fileID: 0} 92 | m_PrefabInstance: {fileID: 0} 93 | m_PrefabAsset: {fileID: 0} 94 | m_GameObject: {fileID: 2557076483051825545} 95 | m_Material: {fileID: 0} 96 | m_IsTrigger: 0 97 | m_Enabled: 1 98 | serializedVersion: 2 99 | m_Radius: 0.5 100 | m_Center: {x: 0, y: 0, z: 0} 101 | --- !u!1 &2839456247898693096 102 | GameObject: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | serializedVersion: 6 108 | m_Component: 109 | - component: {fileID: 2477297412567272144} 110 | - component: {fileID: 1034933829933851243} 111 | - component: {fileID: 7561901167025423695} 112 | - component: {fileID: 2236928941250690101} 113 | m_Layer: 0 114 | m_Name: Face 115 | m_TagString: Untagged 116 | m_Icon: {fileID: 0} 117 | m_NavMeshLayer: 0 118 | m_StaticEditorFlags: 0 119 | m_IsActive: 1 120 | --- !u!4 &2477297412567272144 121 | Transform: 122 | m_ObjectHideFlags: 0 123 | m_CorrespondingSourceObject: {fileID: 0} 124 | m_PrefabInstance: {fileID: 0} 125 | m_PrefabAsset: {fileID: 0} 126 | m_GameObject: {fileID: 2839456247898693096} 127 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 128 | m_LocalPosition: {x: 0, y: 0, z: 0.5} 129 | m_LocalScale: {x: 0.1, y: 0.1, z: 0.5} 130 | m_ConstrainProportionsScale: 0 131 | m_Children: [] 132 | m_Father: {fileID: 6920116202222419103} 133 | m_RootOrder: 0 134 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 135 | --- !u!33 &1034933829933851243 136 | MeshFilter: 137 | m_ObjectHideFlags: 0 138 | m_CorrespondingSourceObject: {fileID: 0} 139 | m_PrefabInstance: {fileID: 0} 140 | m_PrefabAsset: {fileID: 0} 141 | m_GameObject: {fileID: 2839456247898693096} 142 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 143 | --- !u!23 &7561901167025423695 144 | MeshRenderer: 145 | m_ObjectHideFlags: 0 146 | m_CorrespondingSourceObject: {fileID: 0} 147 | m_PrefabInstance: {fileID: 0} 148 | m_PrefabAsset: {fileID: 0} 149 | m_GameObject: {fileID: 2839456247898693096} 150 | m_Enabled: 1 151 | m_CastShadows: 1 152 | m_ReceiveShadows: 1 153 | m_DynamicOccludee: 1 154 | m_StaticShadowCaster: 0 155 | m_MotionVectors: 1 156 | m_LightProbeUsage: 1 157 | m_ReflectionProbeUsage: 1 158 | m_RayTracingMode: 2 159 | m_RayTraceProcedural: 0 160 | m_RenderingLayerMask: 1 161 | m_RendererPriority: 0 162 | m_Materials: 163 | - {fileID: 2100000, guid: 16a4d31172fe8405aa2a315e01f87396, type: 2} 164 | m_StaticBatchInfo: 165 | firstSubMesh: 0 166 | subMeshCount: 0 167 | m_StaticBatchRoot: {fileID: 0} 168 | m_ProbeAnchor: {fileID: 0} 169 | m_LightProbeVolumeOverride: {fileID: 0} 170 | m_ScaleInLightmap: 1 171 | m_ReceiveGI: 1 172 | m_PreserveUVs: 0 173 | m_IgnoreNormalsForChartDetection: 0 174 | m_ImportantGI: 0 175 | m_StitchLightmapSeams: 1 176 | m_SelectedEditorRenderState: 3 177 | m_MinimumChartSize: 4 178 | m_AutoUVMaxDistance: 0.5 179 | m_AutoUVMaxAngle: 89 180 | m_LightmapParameters: {fileID: 0} 181 | m_SortingLayerID: 0 182 | m_SortingLayer: 0 183 | m_SortingOrder: 0 184 | m_AdditionalVertexStreams: {fileID: 0} 185 | --- !u!65 &2236928941250690101 186 | BoxCollider: 187 | m_ObjectHideFlags: 0 188 | m_CorrespondingSourceObject: {fileID: 0} 189 | m_PrefabInstance: {fileID: 0} 190 | m_PrefabAsset: {fileID: 0} 191 | m_GameObject: {fileID: 2839456247898693096} 192 | m_Material: {fileID: 0} 193 | m_IsTrigger: 0 194 | m_Enabled: 1 195 | serializedVersion: 2 196 | m_Size: {x: 1, y: 1, z: 1} 197 | m_Center: {x: 0, y: 0, z: 0} 198 | --- !u!1 &4308843329111450751 199 | GameObject: 200 | m_ObjectHideFlags: 0 201 | m_CorrespondingSourceObject: {fileID: 0} 202 | m_PrefabInstance: {fileID: 0} 203 | m_PrefabAsset: {fileID: 0} 204 | serializedVersion: 6 205 | m_Component: 206 | - component: {fileID: 2326211221164047253} 207 | - component: {fileID: 8011276635846578174} 208 | - component: {fileID: 4054346765732343043} 209 | m_Layer: 0 210 | m_Name: Boid 211 | m_TagString: Untagged 212 | m_Icon: {fileID: 0} 213 | m_NavMeshLayer: 0 214 | m_StaticEditorFlags: 0 215 | m_IsActive: 1 216 | --- !u!4 &2326211221164047253 217 | Transform: 218 | m_ObjectHideFlags: 0 219 | m_CorrespondingSourceObject: {fileID: 0} 220 | m_PrefabInstance: {fileID: 0} 221 | m_PrefabAsset: {fileID: 0} 222 | m_GameObject: {fileID: 4308843329111450751} 223 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 224 | m_LocalPosition: {x: 0, y: 0, z: 0} 225 | m_LocalScale: {x: 1, y: 1, z: 1} 226 | m_ConstrainProportionsScale: 0 227 | m_Children: 228 | - {fileID: 6920116202222419103} 229 | m_Father: {fileID: 0} 230 | m_RootOrder: 0 231 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 232 | --- !u!114 &8011276635846578174 233 | MonoBehaviour: 234 | m_ObjectHideFlags: 0 235 | m_CorrespondingSourceObject: {fileID: 0} 236 | m_PrefabInstance: {fileID: 0} 237 | m_PrefabAsset: {fileID: 0} 238 | m_GameObject: {fileID: 4308843329111450751} 239 | m_Enabled: 1 240 | m_EditorHideFlags: 0 241 | m_Script: {fileID: 11500000, guid: 859b42c7ce6344a64b2678b8820167cc, type: 3} 242 | m_Name: 243 | m_EditorClassIdentifier: 244 | velocity: {x: 0, y: 0, z: 0} 245 | --- !u!65 &4054346765732343043 246 | BoxCollider: 247 | m_ObjectHideFlags: 0 248 | m_CorrespondingSourceObject: {fileID: 0} 249 | m_PrefabInstance: {fileID: 0} 250 | m_PrefabAsset: {fileID: 0} 251 | m_GameObject: {fileID: 4308843329111450751} 252 | m_Material: {fileID: 0} 253 | m_IsTrigger: 0 254 | m_Enabled: 1 255 | serializedVersion: 2 256 | m_Size: {x: 1.05, y: 1.05, z: 1.05} 257 | m_Center: {x: 0, y: 0.5, z: 0} 258 | -------------------------------------------------------------------------------- /Assets/Prefabs/BoidV2.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &2839456247898693096 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 2477297412567272144} 12 | - component: {fileID: 1034933829933851243} 13 | - component: {fileID: 7561901167025423695} 14 | - component: {fileID: 2236928941250690101} 15 | m_Layer: 0 16 | m_Name: Face 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &2477297412567272144 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 2839456247898693096} 29 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0.5} 31 | m_LocalScale: {x: 0.1, y: 0.1, z: 0.5} 32 | m_ConstrainProportionsScale: 0 33 | m_Children: [] 34 | m_Father: {fileID: 1364234871098445172} 35 | m_RootOrder: 0 36 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 37 | --- !u!33 &1034933829933851243 38 | MeshFilter: 39 | m_ObjectHideFlags: 0 40 | m_CorrespondingSourceObject: {fileID: 0} 41 | m_PrefabInstance: {fileID: 0} 42 | m_PrefabAsset: {fileID: 0} 43 | m_GameObject: {fileID: 2839456247898693096} 44 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 45 | --- !u!23 &7561901167025423695 46 | MeshRenderer: 47 | m_ObjectHideFlags: 0 48 | m_CorrespondingSourceObject: {fileID: 0} 49 | m_PrefabInstance: {fileID: 0} 50 | m_PrefabAsset: {fileID: 0} 51 | m_GameObject: {fileID: 2839456247898693096} 52 | m_Enabled: 1 53 | m_CastShadows: 1 54 | m_ReceiveShadows: 1 55 | m_DynamicOccludee: 1 56 | m_StaticShadowCaster: 0 57 | m_MotionVectors: 1 58 | m_LightProbeUsage: 1 59 | m_ReflectionProbeUsage: 1 60 | m_RayTracingMode: 2 61 | m_RayTraceProcedural: 0 62 | m_RenderingLayerMask: 1 63 | m_RendererPriority: 0 64 | m_Materials: 65 | - {fileID: 2100000, guid: 16a4d31172fe8405aa2a315e01f87396, type: 2} 66 | m_StaticBatchInfo: 67 | firstSubMesh: 0 68 | subMeshCount: 0 69 | m_StaticBatchRoot: {fileID: 0} 70 | m_ProbeAnchor: {fileID: 0} 71 | m_LightProbeVolumeOverride: {fileID: 0} 72 | m_ScaleInLightmap: 1 73 | m_ReceiveGI: 1 74 | m_PreserveUVs: 0 75 | m_IgnoreNormalsForChartDetection: 0 76 | m_ImportantGI: 0 77 | m_StitchLightmapSeams: 1 78 | m_SelectedEditorRenderState: 3 79 | m_MinimumChartSize: 4 80 | m_AutoUVMaxDistance: 0.5 81 | m_AutoUVMaxAngle: 89 82 | m_LightmapParameters: {fileID: 0} 83 | m_SortingLayerID: 0 84 | m_SortingLayer: 0 85 | m_SortingOrder: 0 86 | m_AdditionalVertexStreams: {fileID: 0} 87 | --- !u!65 &2236928941250690101 88 | BoxCollider: 89 | m_ObjectHideFlags: 0 90 | m_CorrespondingSourceObject: {fileID: 0} 91 | m_PrefabInstance: {fileID: 0} 92 | m_PrefabAsset: {fileID: 0} 93 | m_GameObject: {fileID: 2839456247898693096} 94 | m_Material: {fileID: 0} 95 | m_IsTrigger: 0 96 | m_Enabled: 1 97 | serializedVersion: 2 98 | m_Size: {x: 1, y: 1, z: 1} 99 | m_Center: {x: 0, y: 0, z: 0} 100 | --- !u!1 &4308843329111450751 101 | GameObject: 102 | m_ObjectHideFlags: 0 103 | m_CorrespondingSourceObject: {fileID: 0} 104 | m_PrefabInstance: {fileID: 0} 105 | m_PrefabAsset: {fileID: 0} 106 | serializedVersion: 6 107 | m_Component: 108 | - component: {fileID: 2326211221164047253} 109 | - component: {fileID: 8011276635846578174} 110 | - component: {fileID: 4054346765732343043} 111 | m_Layer: 0 112 | m_Name: BoidV2 113 | m_TagString: Untagged 114 | m_Icon: {fileID: 0} 115 | m_NavMeshLayer: 0 116 | m_StaticEditorFlags: 0 117 | m_IsActive: 1 118 | --- !u!4 &2326211221164047253 119 | Transform: 120 | m_ObjectHideFlags: 0 121 | m_CorrespondingSourceObject: {fileID: 0} 122 | m_PrefabInstance: {fileID: 0} 123 | m_PrefabAsset: {fileID: 0} 124 | m_GameObject: {fileID: 4308843329111450751} 125 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 126 | m_LocalPosition: {x: 0, y: 0.5, z: 0} 127 | m_LocalScale: {x: 1, y: 1, z: 1} 128 | m_ConstrainProportionsScale: 0 129 | m_Children: 130 | - {fileID: 1364234871098445172} 131 | m_Father: {fileID: 0} 132 | m_RootOrder: 0 133 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 134 | --- !u!114 &8011276635846578174 135 | MonoBehaviour: 136 | m_ObjectHideFlags: 0 137 | m_CorrespondingSourceObject: {fileID: 0} 138 | m_PrefabInstance: {fileID: 0} 139 | m_PrefabAsset: {fileID: 0} 140 | m_GameObject: {fileID: 4308843329111450751} 141 | m_Enabled: 1 142 | m_EditorHideFlags: 0 143 | m_Script: {fileID: 11500000, guid: 859b42c7ce6344a64b2678b8820167cc, type: 3} 144 | m_Name: 145 | m_EditorClassIdentifier: 146 | velocity: {x: 0, y: 0, z: 0} 147 | --- !u!65 &4054346765732343043 148 | BoxCollider: 149 | m_ObjectHideFlags: 0 150 | m_CorrespondingSourceObject: {fileID: 0} 151 | m_PrefabInstance: {fileID: 0} 152 | m_PrefabAsset: {fileID: 0} 153 | m_GameObject: {fileID: 4308843329111450751} 154 | m_Material: {fileID: 0} 155 | m_IsTrigger: 0 156 | m_Enabled: 1 157 | serializedVersion: 2 158 | m_Size: {x: 1.05, y: 1.05, z: 1.05} 159 | m_Center: {x: 0, y: 0.5, z: 0} 160 | --- !u!1 &8396505206759755558 161 | GameObject: 162 | m_ObjectHideFlags: 0 163 | m_CorrespondingSourceObject: {fileID: 0} 164 | m_PrefabInstance: {fileID: 0} 165 | m_PrefabAsset: {fileID: 0} 166 | serializedVersion: 6 167 | m_Component: 168 | - component: {fileID: 1364234871098445172} 169 | - component: {fileID: 7331878145495202034} 170 | - component: {fileID: 2979774244246097169} 171 | - component: {fileID: 6774047905976964340} 172 | m_Layer: 0 173 | m_Name: Body 174 | m_TagString: Untagged 175 | m_Icon: {fileID: 0} 176 | m_NavMeshLayer: 0 177 | m_StaticEditorFlags: 0 178 | m_IsActive: 1 179 | --- !u!4 &1364234871098445172 180 | Transform: 181 | m_ObjectHideFlags: 0 182 | m_CorrespondingSourceObject: {fileID: 0} 183 | m_PrefabInstance: {fileID: 0} 184 | m_PrefabAsset: {fileID: 0} 185 | m_GameObject: {fileID: 8396505206759755558} 186 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 187 | m_LocalPosition: {x: 0, y: 0.5, z: 0} 188 | m_LocalScale: {x: 1, y: 1, z: 1} 189 | m_ConstrainProportionsScale: 0 190 | m_Children: 191 | - {fileID: 2477297412567272144} 192 | m_Father: {fileID: 2326211221164047253} 193 | m_RootOrder: 0 194 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 195 | --- !u!33 &7331878145495202034 196 | MeshFilter: 197 | m_ObjectHideFlags: 0 198 | m_CorrespondingSourceObject: {fileID: 0} 199 | m_PrefabInstance: {fileID: 0} 200 | m_PrefabAsset: {fileID: 0} 201 | m_GameObject: {fileID: 8396505206759755558} 202 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 203 | --- !u!23 &2979774244246097169 204 | MeshRenderer: 205 | m_ObjectHideFlags: 0 206 | m_CorrespondingSourceObject: {fileID: 0} 207 | m_PrefabInstance: {fileID: 0} 208 | m_PrefabAsset: {fileID: 0} 209 | m_GameObject: {fileID: 8396505206759755558} 210 | m_Enabled: 1 211 | m_CastShadows: 1 212 | m_ReceiveShadows: 1 213 | m_DynamicOccludee: 1 214 | m_StaticShadowCaster: 0 215 | m_MotionVectors: 1 216 | m_LightProbeUsage: 1 217 | m_ReflectionProbeUsage: 1 218 | m_RayTracingMode: 2 219 | m_RayTraceProcedural: 0 220 | m_RenderingLayerMask: 1 221 | m_RendererPriority: 0 222 | m_Materials: 223 | - {fileID: 2100000, guid: 9cbb3f0d1d8f3467096d3669aa09b693, type: 2} 224 | m_StaticBatchInfo: 225 | firstSubMesh: 0 226 | subMeshCount: 0 227 | m_StaticBatchRoot: {fileID: 0} 228 | m_ProbeAnchor: {fileID: 0} 229 | m_LightProbeVolumeOverride: {fileID: 0} 230 | m_ScaleInLightmap: 1 231 | m_ReceiveGI: 1 232 | m_PreserveUVs: 0 233 | m_IgnoreNormalsForChartDetection: 0 234 | m_ImportantGI: 0 235 | m_StitchLightmapSeams: 1 236 | m_SelectedEditorRenderState: 3 237 | m_MinimumChartSize: 4 238 | m_AutoUVMaxDistance: 0.5 239 | m_AutoUVMaxAngle: 89 240 | m_LightmapParameters: {fileID: 0} 241 | m_SortingLayerID: 0 242 | m_SortingLayer: 0 243 | m_SortingOrder: 0 244 | m_AdditionalVertexStreams: {fileID: 0} 245 | --- !u!65 &6774047905976964340 246 | BoxCollider: 247 | m_ObjectHideFlags: 0 248 | m_CorrespondingSourceObject: {fileID: 0} 249 | m_PrefabInstance: {fileID: 0} 250 | m_PrefabAsset: {fileID: 0} 251 | m_GameObject: {fileID: 8396505206759755558} 252 | m_Material: {fileID: 0} 253 | m_IsTrigger: 0 254 | m_Enabled: 1 255 | serializedVersion: 2 256 | m_Size: {x: 1, y: 1, z: 1} 257 | m_Center: {x: 0, y: 0, z: 0} 258 | -------------------------------------------------------------------------------- /Assets/Scripts/Simulation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Simulation : MonoBehaviour 6 | { 7 | [Header("Simulation Settings")] 8 | [RangeWithStep(5, 15, 0.5f)] 9 | public float mapHeight; 10 | 11 | [RangeWithStep(5, 15, 0.5f)] 12 | public float mapWidth; 13 | 14 | [Range(1, 10)] 15 | public int startRadius; 16 | 17 | [Range(1, 4000)] 18 | public int numberOfBoids; 19 | 20 | [RangeWithStep(0.1f, 1.0f, 0.1f)] 21 | public float boidScale; 22 | 23 | public GameObject boidPrefab; 24 | public Color boidColor; 25 | 26 | public enum SimulationType 27 | { 28 | v1Unoptimized, 29 | v2Optimized, 30 | v3Compute, 31 | } 32 | 33 | public SimulationType simulationType; 34 | 35 | [HideInInspector] 36 | public List boids; 37 | 38 | [Header("Boid Behavior Range")] 39 | [RangeWithStep(0, 3, 0.5f)] 40 | public float separationRange; 41 | 42 | [RangeWithStep(0, 3, 0.5f)] 43 | public float alignmentRange; 44 | 45 | [RangeWithStep(0, 3, 0.5f)] 46 | public float cohesionRange; 47 | 48 | [Header("Boid Behavior Weights")] 49 | [RangeWithStep(0, 1, 0.1f)] 50 | public float separationFactor; 51 | 52 | [RangeWithStep(0, 1, 0.1f)] 53 | public float alignmentFactor; 54 | 55 | [RangeWithStep(0, 0.2f, 0.025f)] 56 | public float cohesionFactor; 57 | 58 | // todo: maybe normalize values 59 | // normalized values look less cool in the simulation 60 | // [RangeWithStep(0, 0.5f, 0.05f)] 61 | // public float separationFactor; 62 | // [RangeWithStep(0, 0.5f, 0.05f)] 63 | // public float alignmentFactor; 64 | // [RangeWithStep(0, 0.5f, 0.05f)] 65 | // public float cohesionFactor; 66 | 67 | [Header("Boid Speed Settings")] 68 | [RangeWithStep(0, 5, 0.25f)] 69 | public float minSpeed; 70 | 71 | [RangeWithStep(0, 5, 0.25f)] 72 | public float maxSpeed; 73 | 74 | [Range(0, 10)] 75 | public int rotationSpeed; 76 | 77 | public ComputeShader compute; 78 | 79 | BoidSettings CreateBoidSettings() 80 | { 81 | BoidSettings boidSettings = new BoidSettings 82 | { 83 | // simulation settings 84 | mapHeight = mapHeight, 85 | mapWidth = mapWidth, 86 | boidColor = boidColor, 87 | // boid behavior range 88 | separationRange = separationRange, 89 | alignmentRange = alignmentRange, 90 | cohesionRange = cohesionRange, 91 | // boid behavior weights 92 | separationFactor = separationFactor, 93 | alignmentFactor = alignmentFactor, 94 | cohesionFactor = cohesionFactor, 95 | // misc settings 96 | boidScale = boidScale, 97 | minSpeed = minSpeed, 98 | maxSpeed = maxSpeed, 99 | rotationSpeed = rotationSpeed, 100 | }; 101 | return boidSettings; 102 | } 103 | 104 | public void CreateBoids() 105 | { 106 | GameObject liveSimulation = new GameObject("Live Simulation"); 107 | 108 | boids = new List(); 109 | 110 | for (int i = 0; i < numberOfBoids; i++) 111 | { 112 | float angle = i * Mathf.PI * 2 / numberOfBoids; 113 | float x = Mathf.Cos(angle) * startRadius; 114 | float z = Mathf.Sin(angle) * startRadius; 115 | Vector3 position = transform.position + new Vector3(x, 0, z); 116 | 117 | float angleDegrees = -angle * Mathf.Rad2Deg; 118 | Quaternion rotation = Quaternion.Euler(0, angleDegrees, 0); 119 | 120 | GameObject gameObject = Instantiate(boidPrefab, position, rotation); 121 | gameObject.transform.SetParent(liveSimulation.transform); 122 | 123 | Boid b = gameObject.GetComponent(); 124 | BoidSettings boidSettings = CreateBoidSettings(); 125 | b.Initialize(position, rotation, boidSettings); 126 | 127 | boids.Add(gameObject.GetComponent()); 128 | } 129 | } 130 | 131 | void Start() 132 | { 133 | CreateBoids(); 134 | } 135 | 136 | public void UpdateBoidSettings() 137 | { 138 | BoidSettings updatedBoidSettings = CreateBoidSettings(); 139 | foreach (Boid b in boids) 140 | { 141 | // boid will be undefined when the game is not running 142 | // adding this check prevents a console error 143 | if (b == null) 144 | { 145 | continue; 146 | } 147 | 148 | b.boidSettings = updatedBoidSettings; 149 | b.UpdateLocalScale(); 150 | b.UpdateBoidColor(); 151 | } 152 | } 153 | 154 | void Update() 155 | { 156 | CheckForUserInput(); 157 | if (simulationType == SimulationType.v1Unoptimized) 158 | { 159 | RunBoidUpdateV1(); 160 | } 161 | else if (simulationType == SimulationType.v2Optimized) 162 | { 163 | RunBoidUpdateV2(); 164 | } 165 | else if (simulationType == SimulationType.v3Compute) 166 | { 167 | RunBoidUpdateV3(); 168 | } 169 | } 170 | 171 | void RunBoidUpdateV1() 172 | { 173 | for (int i = 0; i < boids.Count; i++) 174 | { 175 | boids[i].UpdateBoidV1(boids); 176 | } 177 | } 178 | 179 | void RunBoidUpdateV2() 180 | { 181 | for (int i = 0; i < boids.Count; i++) 182 | { 183 | boids[i].UpdateBoidV2(boids); 184 | } 185 | } 186 | 187 | // void RunBoidUpdateV3Code() 188 | // { 189 | // BoidCompute[] boidData = new BoidCompute[numberOfBoids]; 190 | // for (int i = 0; i < boids.Count; i++) 191 | // { 192 | // boidData[i] = boids[i].GetComputeShaderData(); 193 | // } 194 | // ComputeBuffer boidBuffer = new ComputeBuffer(numberOfBoids, BoidCompute.Size); 195 | // boidBuffer.SetData(boidData); 196 | // compute.SetBuffer(0, "boids", boidBuffer); 197 | // compute.SetInt("numberOfBoids", boids.Count); 198 | // compute.SetFloat("separationRange", separationRange); 199 | // compute.SetFloat("alignmentRange", alignmentRange); 200 | // compute.SetFloat("cohesionRange", cohesionRange); 201 | // compute.SetFloat("separationFactor", separationFactor); 202 | // compute.SetFloat("alignmentFactor", alignmentFactor); 203 | // compute.SetFloat("cohesionFactor", cohesionFactor); 204 | // compute.Dispatch(0, 128, 1, 1); 205 | // boidBuffer.GetData(boidData); 206 | // for (int i = 0; i < boids.Count; i++) 207 | // { 208 | // boids[i].UpdateBoidV3( 209 | // boidData[i].separationVelocity, 210 | // boidData[i].alignmentVelocity, 211 | // boidData[i].cohesionVelocity 212 | // ); 213 | // } 214 | // boidBuffer.Release(); 215 | // } 216 | 217 | void RunBoidUpdateV3() 218 | { 219 | // note: set up compute shader data 220 | BoidCompute[] boidData = new BoidCompute[numberOfBoids]; 221 | for (int i = 0; i < boids.Count; i++) 222 | { 223 | boidData[i] = boids[i].GetComputeShaderData(); 224 | } 225 | ComputeBuffer boidBuffer = new ComputeBuffer(numberOfBoids, BoidCompute.Size); 226 | boidBuffer.SetData(boidData); 227 | compute.SetBuffer(0, "boids", boidBuffer); 228 | compute.SetInt("numberOfBoids", boids.Count); 229 | compute.SetFloat("separationRange", separationRange); 230 | compute.SetFloat("alignmentRange", alignmentRange); 231 | compute.SetFloat("cohesionRange", cohesionRange); 232 | compute.SetFloat("separationFactor", separationFactor); 233 | compute.SetFloat("alignmentFactor", alignmentFactor); 234 | compute.SetFloat("cohesionFactor", cohesionFactor); 235 | 236 | // note: run compute shader 237 | // todo: change this? 238 | // int threadGroupSize = 1024; 239 | // int threadGroups = Mathf.CeilToInt(numberOfBoids / (float)threadGroupSize); 240 | // compute.Dispatch(0, threadGroups, 1, 1); 241 | // compute.Dispatch(0, numberOfBoids, 1, 1); 242 | compute.Dispatch(0, 128, 1, 1); 243 | boidBuffer.GetData(boidData); 244 | 245 | for (int i = 0; i < boids.Count; i++) 246 | { 247 | boids[i].UpdateBoidV3( 248 | boidData[i].separationVelocity, 249 | boidData[i].alignmentVelocity, 250 | boidData[i].cohesionVelocity 251 | ); 252 | } 253 | 254 | boidBuffer.Release(); 255 | } 256 | 257 | void CheckForUserInput() 258 | { 259 | if (Input.GetMouseButtonDown(0)) 260 | { 261 | Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); 262 | RaycastHit hit; 263 | 264 | if (Physics.Raycast(ray, out hit)) 265 | { 266 | GameObject boidGameObject = hit.collider.gameObject; 267 | Boid b = boidGameObject.GetComponent(); 268 | if (b != null) 269 | { 270 | b.ToggleDebugView(); 271 | } 272 | } 273 | } 274 | 275 | if (Input.GetKeyDown(KeyCode.Space)) 276 | { 277 | DisableAllBoidDebugViews(); 278 | } 279 | } 280 | 281 | void DisableAllBoidDebugViews() 282 | { 283 | foreach (Boid b in boids) 284 | { 285 | b.DisableDebugView(); 286 | } 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | - serializedVersion: 3 297 | m_Name: Enable Debug Button 1 298 | descriptiveName: 299 | descriptiveNegativeName: 300 | negativeButton: 301 | positiveButton: left ctrl 302 | altNegativeButton: 303 | altPositiveButton: joystick button 8 304 | gravity: 0 305 | dead: 0 306 | sensitivity: 0 307 | snap: 0 308 | invert: 0 309 | type: 0 310 | axis: 0 311 | joyNum: 0 312 | - serializedVersion: 3 313 | m_Name: Enable Debug Button 2 314 | descriptiveName: 315 | descriptiveNegativeName: 316 | negativeButton: 317 | positiveButton: backspace 318 | altNegativeButton: 319 | altPositiveButton: joystick button 9 320 | gravity: 0 321 | dead: 0 322 | sensitivity: 0 323 | snap: 0 324 | invert: 0 325 | type: 0 326 | axis: 0 327 | joyNum: 0 328 | - serializedVersion: 3 329 | m_Name: Debug Reset 330 | descriptiveName: 331 | descriptiveNegativeName: 332 | negativeButton: 333 | positiveButton: left alt 334 | altNegativeButton: 335 | altPositiveButton: joystick button 1 336 | gravity: 0 337 | dead: 0 338 | sensitivity: 0 339 | snap: 0 340 | invert: 0 341 | type: 0 342 | axis: 0 343 | joyNum: 0 344 | - serializedVersion: 3 345 | m_Name: Debug Next 346 | descriptiveName: 347 | descriptiveNegativeName: 348 | negativeButton: 349 | positiveButton: page down 350 | altNegativeButton: 351 | altPositiveButton: joystick button 5 352 | gravity: 0 353 | dead: 0 354 | sensitivity: 0 355 | snap: 0 356 | invert: 0 357 | type: 0 358 | axis: 0 359 | joyNum: 0 360 | - serializedVersion: 3 361 | m_Name: Debug Previous 362 | descriptiveName: 363 | descriptiveNegativeName: 364 | negativeButton: 365 | positiveButton: page up 366 | altNegativeButton: 367 | altPositiveButton: joystick button 4 368 | gravity: 0 369 | dead: 0 370 | sensitivity: 0 371 | snap: 0 372 | invert: 0 373 | type: 0 374 | axis: 0 375 | joyNum: 0 376 | - serializedVersion: 3 377 | m_Name: Debug Validate 378 | descriptiveName: 379 | descriptiveNegativeName: 380 | negativeButton: 381 | positiveButton: return 382 | altNegativeButton: 383 | altPositiveButton: joystick button 0 384 | gravity: 0 385 | dead: 0 386 | sensitivity: 0 387 | snap: 0 388 | invert: 0 389 | type: 0 390 | axis: 0 391 | joyNum: 0 392 | - serializedVersion: 3 393 | m_Name: Debug Persistent 394 | descriptiveName: 395 | descriptiveNegativeName: 396 | negativeButton: 397 | positiveButton: right shift 398 | altNegativeButton: 399 | altPositiveButton: joystick button 2 400 | gravity: 0 401 | dead: 0 402 | sensitivity: 0 403 | snap: 0 404 | invert: 0 405 | type: 0 406 | axis: 0 407 | joyNum: 0 408 | - serializedVersion: 3 409 | m_Name: Debug Multiplier 410 | descriptiveName: 411 | descriptiveNegativeName: 412 | negativeButton: 413 | positiveButton: left shift 414 | altNegativeButton: 415 | altPositiveButton: joystick button 3 416 | gravity: 0 417 | dead: 0 418 | sensitivity: 0 419 | snap: 0 420 | invert: 0 421 | type: 0 422 | axis: 0 423 | joyNum: 0 424 | - serializedVersion: 3 425 | m_Name: Debug Horizontal 426 | descriptiveName: 427 | descriptiveNegativeName: 428 | negativeButton: left 429 | positiveButton: right 430 | altNegativeButton: 431 | altPositiveButton: 432 | gravity: 1000 433 | dead: 0.001 434 | sensitivity: 1000 435 | snap: 0 436 | invert: 0 437 | type: 0 438 | axis: 0 439 | joyNum: 0 440 | - serializedVersion: 3 441 | m_Name: Debug Vertical 442 | descriptiveName: 443 | descriptiveNegativeName: 444 | negativeButton: down 445 | positiveButton: up 446 | altNegativeButton: 447 | altPositiveButton: 448 | gravity: 1000 449 | dead: 0.001 450 | sensitivity: 1000 451 | snap: 0 452 | invert: 0 453 | type: 0 454 | axis: 0 455 | joyNum: 0 456 | - serializedVersion: 3 457 | m_Name: Debug Vertical 458 | descriptiveName: 459 | descriptiveNegativeName: 460 | negativeButton: down 461 | positiveButton: up 462 | altNegativeButton: 463 | altPositiveButton: 464 | gravity: 1000 465 | dead: 0.001 466 | sensitivity: 1000 467 | snap: 0 468 | invert: 0 469 | type: 2 470 | axis: 6 471 | joyNum: 0 472 | - serializedVersion: 3 473 | m_Name: Debug Horizontal 474 | descriptiveName: 475 | descriptiveNegativeName: 476 | negativeButton: left 477 | positiveButton: right 478 | altNegativeButton: 479 | altPositiveButton: 480 | gravity: 1000 481 | dead: 0.001 482 | sensitivity: 1000 483 | snap: 0 484 | invert: 0 485 | type: 2 486 | axis: 5 487 | joyNum: 0 488 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": { 4 | "version": "1.8.4", 5 | "depth": 1, 6 | "source": "registry", 7 | "dependencies": { 8 | "com.unity.mathematics": "1.2.1" 9 | }, 10 | "url": "https://packages.unity.com" 11 | }, 12 | "com.unity.collab-proxy": { 13 | "version": "2.0.4", 14 | "depth": 0, 15 | "source": "registry", 16 | "dependencies": {}, 17 | "url": "https://packages.unity.com" 18 | }, 19 | "com.unity.ext.nunit": { 20 | "version": "1.0.6", 21 | "depth": 1, 22 | "source": "registry", 23 | "dependencies": {}, 24 | "url": "https://packages.unity.com" 25 | }, 26 | "com.unity.ide.rider": { 27 | "version": "3.0.21", 28 | "depth": 0, 29 | "source": "registry", 30 | "dependencies": { 31 | "com.unity.ext.nunit": "1.0.6" 32 | }, 33 | "url": "https://packages.unity.com" 34 | }, 35 | "com.unity.ide.visualstudio": { 36 | "version": "2.0.18", 37 | "depth": 0, 38 | "source": "registry", 39 | "dependencies": { 40 | "com.unity.test-framework": "1.1.9" 41 | }, 42 | "url": "https://packages.unity.com" 43 | }, 44 | "com.unity.ide.vscode": { 45 | "version": "1.2.5", 46 | "depth": 0, 47 | "source": "registry", 48 | "dependencies": {}, 49 | "url": "https://packages.unity.com" 50 | }, 51 | "com.unity.mathematics": { 52 | "version": "1.2.6", 53 | "depth": 1, 54 | "source": "registry", 55 | "dependencies": {}, 56 | "url": "https://packages.unity.com" 57 | }, 58 | "com.unity.render-pipelines.core": { 59 | "version": "12.1.11", 60 | "depth": 1, 61 | "source": "builtin", 62 | "dependencies": { 63 | "com.unity.ugui": "1.0.0", 64 | "com.unity.modules.physics": "1.0.0", 65 | "com.unity.modules.jsonserialize": "1.0.0" 66 | } 67 | }, 68 | "com.unity.render-pipelines.universal": { 69 | "version": "12.1.11", 70 | "depth": 0, 71 | "source": "builtin", 72 | "dependencies": { 73 | "com.unity.mathematics": "1.2.1", 74 | "com.unity.burst": "1.8.4", 75 | "com.unity.render-pipelines.core": "12.1.11", 76 | "com.unity.shadergraph": "12.1.11" 77 | } 78 | }, 79 | "com.unity.searcher": { 80 | "version": "4.9.1", 81 | "depth": 2, 82 | "source": "registry", 83 | "dependencies": {}, 84 | "url": "https://packages.unity.com" 85 | }, 86 | "com.unity.shadergraph": { 87 | "version": "12.1.11", 88 | "depth": 1, 89 | "source": "builtin", 90 | "dependencies": { 91 | "com.unity.render-pipelines.core": "12.1.11", 92 | "com.unity.searcher": "4.9.1" 93 | } 94 | }, 95 | "com.unity.test-framework": { 96 | "version": "1.1.33", 97 | "depth": 0, 98 | "source": "registry", 99 | "dependencies": { 100 | "com.unity.ext.nunit": "1.0.6", 101 | "com.unity.modules.imgui": "1.0.0", 102 | "com.unity.modules.jsonserialize": "1.0.0" 103 | }, 104 | "url": "https://packages.unity.com" 105 | }, 106 | "com.unity.textmeshpro": { 107 | "version": "3.0.6", 108 | "depth": 0, 109 | "source": "registry", 110 | "dependencies": { 111 | "com.unity.ugui": "1.0.0" 112 | }, 113 | "url": "https://packages.unity.com" 114 | }, 115 | "com.unity.timeline": { 116 | "version": "1.6.5", 117 | "depth": 0, 118 | "source": "registry", 119 | "dependencies": { 120 | "com.unity.modules.director": "1.0.0", 121 | "com.unity.modules.animation": "1.0.0", 122 | "com.unity.modules.audio": "1.0.0", 123 | "com.unity.modules.particlesystem": "1.0.0" 124 | }, 125 | "url": "https://packages.unity.com" 126 | }, 127 | "com.unity.ugui": { 128 | "version": "1.0.0", 129 | "depth": 0, 130 | "source": "builtin", 131 | "dependencies": { 132 | "com.unity.modules.ui": "1.0.0", 133 | "com.unity.modules.imgui": "1.0.0" 134 | } 135 | }, 136 | "com.unity.visualscripting": { 137 | "version": "1.8.0", 138 | "depth": 0, 139 | "source": "registry", 140 | "dependencies": { 141 | "com.unity.ugui": "1.0.0", 142 | "com.unity.modules.jsonserialize": "1.0.0" 143 | }, 144 | "url": "https://packages.unity.com" 145 | }, 146 | "com.unity.modules.ai": { 147 | "version": "1.0.0", 148 | "depth": 0, 149 | "source": "builtin", 150 | "dependencies": {} 151 | }, 152 | "com.unity.modules.androidjni": { 153 | "version": "1.0.0", 154 | "depth": 0, 155 | "source": "builtin", 156 | "dependencies": {} 157 | }, 158 | "com.unity.modules.animation": { 159 | "version": "1.0.0", 160 | "depth": 0, 161 | "source": "builtin", 162 | "dependencies": {} 163 | }, 164 | "com.unity.modules.assetbundle": { 165 | "version": "1.0.0", 166 | "depth": 0, 167 | "source": "builtin", 168 | "dependencies": {} 169 | }, 170 | "com.unity.modules.audio": { 171 | "version": "1.0.0", 172 | "depth": 0, 173 | "source": "builtin", 174 | "dependencies": {} 175 | }, 176 | "com.unity.modules.cloth": { 177 | "version": "1.0.0", 178 | "depth": 0, 179 | "source": "builtin", 180 | "dependencies": { 181 | "com.unity.modules.physics": "1.0.0" 182 | } 183 | }, 184 | "com.unity.modules.director": { 185 | "version": "1.0.0", 186 | "depth": 0, 187 | "source": "builtin", 188 | "dependencies": { 189 | "com.unity.modules.audio": "1.0.0", 190 | "com.unity.modules.animation": "1.0.0" 191 | } 192 | }, 193 | "com.unity.modules.imageconversion": { 194 | "version": "1.0.0", 195 | "depth": 0, 196 | "source": "builtin", 197 | "dependencies": {} 198 | }, 199 | "com.unity.modules.imgui": { 200 | "version": "1.0.0", 201 | "depth": 0, 202 | "source": "builtin", 203 | "dependencies": {} 204 | }, 205 | "com.unity.modules.jsonserialize": { 206 | "version": "1.0.0", 207 | "depth": 0, 208 | "source": "builtin", 209 | "dependencies": {} 210 | }, 211 | "com.unity.modules.particlesystem": { 212 | "version": "1.0.0", 213 | "depth": 0, 214 | "source": "builtin", 215 | "dependencies": {} 216 | }, 217 | "com.unity.modules.physics": { 218 | "version": "1.0.0", 219 | "depth": 0, 220 | "source": "builtin", 221 | "dependencies": {} 222 | }, 223 | "com.unity.modules.physics2d": { 224 | "version": "1.0.0", 225 | "depth": 0, 226 | "source": "builtin", 227 | "dependencies": {} 228 | }, 229 | "com.unity.modules.screencapture": { 230 | "version": "1.0.0", 231 | "depth": 0, 232 | "source": "builtin", 233 | "dependencies": { 234 | "com.unity.modules.imageconversion": "1.0.0" 235 | } 236 | }, 237 | "com.unity.modules.subsystems": { 238 | "version": "1.0.0", 239 | "depth": 1, 240 | "source": "builtin", 241 | "dependencies": { 242 | "com.unity.modules.jsonserialize": "1.0.0" 243 | } 244 | }, 245 | "com.unity.modules.terrain": { 246 | "version": "1.0.0", 247 | "depth": 0, 248 | "source": "builtin", 249 | "dependencies": {} 250 | }, 251 | "com.unity.modules.terrainphysics": { 252 | "version": "1.0.0", 253 | "depth": 0, 254 | "source": "builtin", 255 | "dependencies": { 256 | "com.unity.modules.physics": "1.0.0", 257 | "com.unity.modules.terrain": "1.0.0" 258 | } 259 | }, 260 | "com.unity.modules.tilemap": { 261 | "version": "1.0.0", 262 | "depth": 0, 263 | "source": "builtin", 264 | "dependencies": { 265 | "com.unity.modules.physics2d": "1.0.0" 266 | } 267 | }, 268 | "com.unity.modules.ui": { 269 | "version": "1.0.0", 270 | "depth": 0, 271 | "source": "builtin", 272 | "dependencies": {} 273 | }, 274 | "com.unity.modules.uielements": { 275 | "version": "1.0.0", 276 | "depth": 0, 277 | "source": "builtin", 278 | "dependencies": { 279 | "com.unity.modules.ui": "1.0.0", 280 | "com.unity.modules.imgui": "1.0.0", 281 | "com.unity.modules.jsonserialize": "1.0.0", 282 | "com.unity.modules.uielementsnative": "1.0.0" 283 | } 284 | }, 285 | "com.unity.modules.uielementsnative": { 286 | "version": "1.0.0", 287 | "depth": 1, 288 | "source": "builtin", 289 | "dependencies": { 290 | "com.unity.modules.ui": "1.0.0", 291 | "com.unity.modules.imgui": "1.0.0", 292 | "com.unity.modules.jsonserialize": "1.0.0" 293 | } 294 | }, 295 | "com.unity.modules.umbra": { 296 | "version": "1.0.0", 297 | "depth": 0, 298 | "source": "builtin", 299 | "dependencies": {} 300 | }, 301 | "com.unity.modules.unityanalytics": { 302 | "version": "1.0.0", 303 | "depth": 0, 304 | "source": "builtin", 305 | "dependencies": { 306 | "com.unity.modules.unitywebrequest": "1.0.0", 307 | "com.unity.modules.jsonserialize": "1.0.0" 308 | } 309 | }, 310 | "com.unity.modules.unitywebrequest": { 311 | "version": "1.0.0", 312 | "depth": 0, 313 | "source": "builtin", 314 | "dependencies": {} 315 | }, 316 | "com.unity.modules.unitywebrequestassetbundle": { 317 | "version": "1.0.0", 318 | "depth": 0, 319 | "source": "builtin", 320 | "dependencies": { 321 | "com.unity.modules.assetbundle": "1.0.0", 322 | "com.unity.modules.unitywebrequest": "1.0.0" 323 | } 324 | }, 325 | "com.unity.modules.unitywebrequestaudio": { 326 | "version": "1.0.0", 327 | "depth": 0, 328 | "source": "builtin", 329 | "dependencies": { 330 | "com.unity.modules.unitywebrequest": "1.0.0", 331 | "com.unity.modules.audio": "1.0.0" 332 | } 333 | }, 334 | "com.unity.modules.unitywebrequesttexture": { 335 | "version": "1.0.0", 336 | "depth": 0, 337 | "source": "builtin", 338 | "dependencies": { 339 | "com.unity.modules.unitywebrequest": "1.0.0", 340 | "com.unity.modules.imageconversion": "1.0.0" 341 | } 342 | }, 343 | "com.unity.modules.unitywebrequestwww": { 344 | "version": "1.0.0", 345 | "depth": 0, 346 | "source": "builtin", 347 | "dependencies": { 348 | "com.unity.modules.unitywebrequest": "1.0.0", 349 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 350 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 351 | "com.unity.modules.audio": "1.0.0", 352 | "com.unity.modules.assetbundle": "1.0.0", 353 | "com.unity.modules.imageconversion": "1.0.0" 354 | } 355 | }, 356 | "com.unity.modules.vehicles": { 357 | "version": "1.0.0", 358 | "depth": 0, 359 | "source": "builtin", 360 | "dependencies": { 361 | "com.unity.modules.physics": "1.0.0" 362 | } 363 | }, 364 | "com.unity.modules.video": { 365 | "version": "1.0.0", 366 | "depth": 0, 367 | "source": "builtin", 368 | "dependencies": { 369 | "com.unity.modules.audio": "1.0.0", 370 | "com.unity.modules.ui": "1.0.0", 371 | "com.unity.modules.unitywebrequest": "1.0.0" 372 | } 373 | }, 374 | "com.unity.modules.vr": { 375 | "version": "1.0.0", 376 | "depth": 0, 377 | "source": "builtin", 378 | "dependencies": { 379 | "com.unity.modules.jsonserialize": "1.0.0", 380 | "com.unity.modules.physics": "1.0.0", 381 | "com.unity.modules.xr": "1.0.0" 382 | } 383 | }, 384 | "com.unity.modules.wind": { 385 | "version": "1.0.0", 386 | "depth": 0, 387 | "source": "builtin", 388 | "dependencies": {} 389 | }, 390 | "com.unity.modules.xr": { 391 | "version": "1.0.0", 392 | "depth": 0, 393 | "source": "builtin", 394 | "dependencies": { 395 | "com.unity.modules.physics": "1.0.0", 396 | "com.unity.modules.jsonserialize": "1.0.0", 397 | "com.unity.modules.subsystems": "1.0.0" 398 | } 399 | } 400 | } 401 | } 402 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 58 | Public License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-NonCommercial-ShareAlike 4.0 International Public License 63 | ("Public License"). To the extent this Public License may be 64 | interpreted as a contract, You are granted the Licensed Rights in 65 | consideration of Your acceptance of these terms and conditions, and the 66 | Licensor grants You such rights in consideration of benefits the 67 | Licensor receives from making the Licensed Material available under 68 | these terms and conditions. 69 | 70 | Section 1 -- Definitions. 71 | 72 | a. Adapted Material means material subject to Copyright and Similar 73 | Rights that is derived from or based upon the Licensed Material 74 | and in which the Licensed Material is translated, altered, 75 | arranged, transformed, or otherwise modified in a manner requiring 76 | permission under the Copyright and Similar Rights held by the 77 | Licensor. For purposes of this Public License, where the Licensed 78 | Material is a musical work, performance, or sound recording, 79 | Adapted Material is always produced where the Licensed Material is 80 | synched in timed relation with a moving image. 81 | 82 | b. Adapter's License means the license You apply to Your Copyright 83 | and Similar Rights in Your contributions to Adapted Material in 84 | accordance with the terms and conditions of this Public License. 85 | 86 | c. BY-NC-SA Compatible License means a license listed at 87 | creativecommons.org/compatiblelicenses, approved by Creative 88 | Commons as essentially the equivalent of this Public License. 89 | 90 | d. Copyright and Similar Rights means copyright and/or similar rights 91 | closely related to copyright including, without limitation, 92 | performance, broadcast, sound recording, and Sui Generis Database 93 | Rights, without regard to how the rights are labeled or 94 | categorized. For purposes of this Public License, the rights 95 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 96 | Rights. 97 | 98 | e. Effective Technological Measures means those measures that, in the 99 | absence of proper authority, may not be circumvented under laws 100 | fulfilling obligations under Article 11 of the WIPO Copyright 101 | Treaty adopted on December 20, 1996, and/or similar international 102 | agreements. 103 | 104 | f. Exceptions and Limitations means fair use, fair dealing, and/or 105 | any other exception or limitation to Copyright and Similar Rights 106 | that applies to Your use of the Licensed Material. 107 | 108 | g. License Elements means the license attributes listed in the name 109 | of a Creative Commons Public License. The License Elements of this 110 | Public License are Attribution, NonCommercial, and ShareAlike. 111 | 112 | h. Licensed Material means the artistic or literary work, database, 113 | or other material to which the Licensor applied this Public 114 | License. 115 | 116 | i. Licensed Rights means the rights granted to You subject to the 117 | terms and conditions of this Public License, which are limited to 118 | all Copyright and Similar Rights that apply to Your use of the 119 | Licensed Material and that the Licensor has authority to license. 120 | 121 | j. Licensor means the individual(s) or entity(ies) granting rights 122 | under this Public License. 123 | 124 | k. NonCommercial means not primarily intended for or directed towards 125 | commercial advantage or monetary compensation. For purposes of 126 | this Public License, the exchange of the Licensed Material for 127 | other material subject to Copyright and Similar Rights by digital 128 | file-sharing or similar means is NonCommercial provided there is 129 | no payment of monetary compensation in connection with the 130 | exchange. 131 | 132 | l. Share means to provide material to the public by any means or 133 | process that requires permission under the Licensed Rights, such 134 | as reproduction, public display, public performance, distribution, 135 | dissemination, communication, or importation, and to make material 136 | available to the public including in ways that members of the 137 | public may access the material from a place and at a time 138 | individually chosen by them. 139 | 140 | m. Sui Generis Database Rights means rights other than copyright 141 | resulting from Directive 96/9/EC of the European Parliament and of 142 | the Council of 11 March 1996 on the legal protection of databases, 143 | as amended and/or succeeded, as well as other essentially 144 | equivalent rights anywhere in the world. 145 | 146 | n. You means the individual or entity exercising the Licensed Rights 147 | under this Public License. Your has a corresponding meaning. 148 | 149 | Section 2 -- Scope. 150 | 151 | a. License grant. 152 | 153 | 1. Subject to the terms and conditions of this Public License, 154 | the Licensor hereby grants You a worldwide, royalty-free, 155 | non-sublicensable, non-exclusive, irrevocable license to 156 | exercise the Licensed Rights in the Licensed Material to: 157 | 158 | a. reproduce and Share the Licensed Material, in whole or 159 | in part, for NonCommercial purposes only; and 160 | 161 | b. produce, reproduce, and Share Adapted Material for 162 | NonCommercial purposes only. 163 | 164 | 2. Exceptions and Limitations. For the avoidance of doubt, where 165 | Exceptions and Limitations apply to Your use, this Public 166 | License does not apply, and You do not need to comply with 167 | its terms and conditions. 168 | 169 | 3. Term. The term of this Public License is specified in Section 170 | 6(a). 171 | 172 | 4. Media and formats; technical modifications allowed. The 173 | Licensor authorizes You to exercise the Licensed Rights in 174 | all media and formats whether now known or hereafter created, 175 | and to make technical modifications necessary to do so. The 176 | Licensor waives and/or agrees not to assert any right or 177 | authority to forbid You from making technical modifications 178 | necessary to exercise the Licensed Rights, including 179 | technical modifications necessary to circumvent Effective 180 | Technological Measures. For purposes of this Public License, 181 | simply making modifications authorized by this Section 2(a) 182 | (4) never produces Adapted Material. 183 | 184 | 5. Downstream recipients. 185 | 186 | a. Offer from the Licensor -- Licensed Material. Every 187 | recipient of the Licensed Material automatically 188 | receives an offer from the Licensor to exercise the 189 | Licensed Rights under the terms and conditions of this 190 | Public License. 191 | 192 | b. Additional offer from the Licensor -- Adapted Material. 193 | Every recipient of Adapted Material from You 194 | automatically receives an offer from the Licensor to 195 | exercise the Licensed Rights in the Adapted Material 196 | under the conditions of the Adapter's License You apply. 197 | 198 | c. No downstream restrictions. You may not offer or impose 199 | any additional or different terms or conditions on, or 200 | apply any Effective Technological Measures to, the 201 | Licensed Material if doing so restricts exercise of the 202 | Licensed Rights by any recipient of the Licensed 203 | Material. 204 | 205 | 6. No endorsement. Nothing in this Public License constitutes or 206 | may be construed as permission to assert or imply that You 207 | are, or that Your use of the Licensed Material is, connected 208 | with, or sponsored, endorsed, or granted official status by, 209 | the Licensor or others designated to receive attribution as 210 | provided in Section 3(a)(1)(A)(i). 211 | 212 | b. Other rights. 213 | 214 | 1. Moral rights, such as the right of integrity, are not 215 | licensed under this Public License, nor are publicity, 216 | privacy, and/or other similar personality rights; however, to 217 | the extent possible, the Licensor waives and/or agrees not to 218 | assert any such rights held by the Licensor to the limited 219 | extent necessary to allow You to exercise the Licensed 220 | Rights, but not otherwise. 221 | 222 | 2. Patent and trademark rights are not licensed under this 223 | Public License. 224 | 225 | 3. To the extent possible, the Licensor waives any right to 226 | collect royalties from You for the exercise of the Licensed 227 | Rights, whether directly or through a collecting society 228 | under any voluntary or waivable statutory or compulsory 229 | licensing scheme. In all other cases the Licensor expressly 230 | reserves any right to collect such royalties, including when 231 | the Licensed Material is used other than for NonCommercial 232 | purposes. 233 | 234 | Section 3 -- License Conditions. 235 | 236 | Your exercise of the Licensed Rights is expressly made subject to the 237 | following conditions. 238 | 239 | a. Attribution. 240 | 241 | 1. If You Share the Licensed Material (including in modified 242 | form), You must: 243 | 244 | a. retain the following if it is supplied by the Licensor 245 | with the Licensed Material: 246 | 247 | i. identification of the creator(s) of the Licensed 248 | Material and any others designated to receive 249 | attribution, in any reasonable manner requested by 250 | the Licensor (including by pseudonym if 251 | designated); 252 | 253 | ii. a copyright notice; 254 | 255 | iii. a notice that refers to this Public License; 256 | 257 | iv. a notice that refers to the disclaimer of 258 | warranties; 259 | 260 | v. a URI or hyperlink to the Licensed Material to the 261 | extent reasonably practicable; 262 | 263 | b. indicate if You modified the Licensed Material and 264 | retain an indication of any previous modifications; and 265 | 266 | c. indicate the Licensed Material is licensed under this 267 | Public License, and include the text of, or the URI or 268 | hyperlink to, this Public License. 269 | 270 | 2. You may satisfy the conditions in Section 3(a)(1) in any 271 | reasonable manner based on the medium, means, and context in 272 | which You Share the Licensed Material. For example, it may be 273 | reasonable to satisfy the conditions by providing a URI or 274 | hyperlink to a resource that includes the required 275 | information. 276 | 3. If requested by the Licensor, You must remove any of the 277 | information required by Section 3(a)(1)(A) to the extent 278 | reasonably practicable. 279 | 280 | b. ShareAlike. 281 | 282 | In addition to the conditions in Section 3(a), if You Share 283 | Adapted Material You produce, the following conditions also apply. 284 | 285 | 1. The Adapter's License You apply must be a Creative Commons 286 | license with the same License Elements, this version or 287 | later, or a BY-NC-SA Compatible License. 288 | 289 | 2. You must include the text of, or the URI or hyperlink to, the 290 | Adapter's License You apply. You may satisfy this condition 291 | in any reasonable manner based on the medium, means, and 292 | context in which You Share Adapted Material. 293 | 294 | 3. You may not offer or impose any additional or different terms 295 | or conditions on, or apply any Effective Technological 296 | Measures to, Adapted Material that restrict exercise of the 297 | rights granted under the Adapter's License You apply. 298 | 299 | Section 4 -- Sui Generis Database Rights. 300 | 301 | Where the Licensed Rights include Sui Generis Database Rights that 302 | apply to Your use of the Licensed Material: 303 | 304 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 305 | to extract, reuse, reproduce, and Share all or a substantial 306 | portion of the contents of the database for NonCommercial purposes 307 | only; 308 | 309 | b. if You include all or a substantial portion of the database 310 | contents in a database in which You have Sui Generis Database 311 | Rights, then the database in which You have Sui Generis Database 312 | Rights (but not its individual contents) is Adapted Material, 313 | including for purposes of Section 3(b); and 314 | 315 | c. You must comply with the conditions in Section 3(a) if You Share 316 | all or a substantial portion of the contents of the database. 317 | 318 | For the avoidance of doubt, this Section 4 supplements and does not 319 | replace Your obligations under this Public License where the Licensed 320 | Rights include other Copyright and Similar Rights. 321 | 322 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 323 | 324 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 325 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 326 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 327 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 328 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 329 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 330 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 331 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 332 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 333 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 334 | 335 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 336 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 337 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 338 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 339 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 340 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 341 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 342 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 343 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 344 | 345 | c. The disclaimer of warranties and limitation of liability provided 346 | above shall be interpreted in a manner that, to the extent 347 | possible, most closely approximates an absolute disclaimer and 348 | waiver of all liability. 349 | 350 | Section 6 -- Term and Termination. 351 | 352 | a. This Public License applies for the term of the Copyright and 353 | Similar Rights licensed here. However, if You fail to comply with 354 | this Public License, then Your rights under this Public License 355 | terminate automatically. 356 | 357 | b. Where Your right to use the Licensed Material has terminated under 358 | Section 6(a), it reinstates: 359 | 360 | 1. automatically as of the date the violation is cured, provided 361 | it is cured within 30 days of Your discovery of the 362 | violation; or 363 | 364 | 2. upon express reinstatement by the Licensor. 365 | 366 | For the avoidance of doubt, this Section 6(b) does not affect any 367 | right the Licensor may have to seek remedies for Your violations 368 | of this Public License. 369 | 370 | c. For the avoidance of doubt, the Licensor may also offer the 371 | Licensed Material under separate terms or conditions or stop 372 | distributing the Licensed Material at any time; however, doing so 373 | will not terminate this Public License. 374 | 375 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 376 | License. 377 | 378 | Section 7 -- Other Terms and Conditions. 379 | 380 | a. The Licensor shall not be bound by any additional or different 381 | terms or conditions communicated by You unless expressly agreed. 382 | 383 | b. Any arrangements, understandings, or agreements regarding the 384 | Licensed Material not stated herein are separate from and 385 | independent of the terms and conditions of this Public License. 386 | 387 | Section 8 -- Interpretation. 388 | 389 | a. For the avoidance of doubt, this Public License does not, and 390 | shall not be interpreted to, reduce, limit, restrict, or impose 391 | conditions on any use of the Licensed Material that could lawfully 392 | be made without permission under this Public License. 393 | 394 | b. To the extent possible, if any provision of this Public License is 395 | deemed unenforceable, it shall be automatically reformed to the 396 | minimum extent necessary to make it enforceable. If the provision 397 | cannot be reformed, it shall be severed from this Public License 398 | without affecting the enforceability of the remaining terms and 399 | conditions. 400 | 401 | c. No term or condition of this Public License will be waived and no 402 | failure to comply consented to unless expressly agreed to by the 403 | Licensor. 404 | 405 | d. Nothing in this Public License constitutes or may be interpreted 406 | as a limitation upon, or waiver of, any privileges and immunities 407 | that apply to the Licensor or You, including from the legal 408 | processes of any jurisdiction or authority. 409 | 410 | ======================================================================= 411 | 412 | Creative Commons is not a party to its public 413 | licenses. Notwithstanding, Creative Commons may elect to apply one of 414 | its public licenses to material it publishes and in those instances 415 | will be considered the “Licensor.” The text of the Creative Commons 416 | public licenses is dedicated to the public domain under the CC0 Public 417 | Domain Dedication. Except for the limited purpose of indicating that 418 | material is shared under a Creative Commons public license or as 419 | otherwise permitted by the Creative Commons policies published at 420 | creativecommons.org/policies, Creative Commons does not authorize the 421 | use of the trademark "Creative Commons" or any other trademark or logo 422 | of Creative Commons without its prior written consent including, 423 | without limitation, in connection with any unauthorized modifications 424 | to any of its public licenses or any other arrangements, 425 | understandings, or agreements concerning use of licensed material. For 426 | the avoidance of doubt, this paragraph does not form part of the 427 | public licenses. 428 | 429 | Creative Commons may be contacted at creativecommons.org. 430 | -------------------------------------------------------------------------------- /Assets/Scripts/Boid.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | public struct BoidSettings 7 | { 8 | // simulation settings 9 | public float mapHeight; 10 | public float mapWidth; 11 | public Color boidColor; 12 | 13 | // boid behavior range 14 | public float separationRange; 15 | public float alignmentRange; 16 | public float cohesionRange; 17 | 18 | // boid behavior weights 19 | public float separationFactor; 20 | public float alignmentFactor; 21 | public float cohesionFactor; 22 | 23 | // misc settings 24 | public float boidScale; 25 | public float minSpeed; 26 | public float maxSpeed; 27 | public int rotationSpeed; 28 | } 29 | 30 | public struct BoidCompute 31 | { 32 | public Vector3 velocity; 33 | public Vector3 position; 34 | public Vector3 separationVelocity; 35 | public Vector3 alignmentVelocity; 36 | public Vector3 cohesionVelocity; 37 | 38 | public static int Size 39 | { 40 | get { return sizeof(float) * 3 * 5; } 41 | } 42 | } 43 | 44 | public class Boid : MonoBehaviour 45 | { 46 | public BoidSettings boidSettings; 47 | public Vector3 velocity; 48 | bool debugViewEnabled; 49 | 50 | public void Initialize(Vector3 position, Quaternion rotation, BoidSettings boidSettings) 51 | { 52 | this.boidSettings = boidSettings; 53 | this.velocity = rotation * Vector3.forward * this.boidSettings.maxSpeed; 54 | this.debugViewEnabled = false; 55 | this.UpdateLocalScale(); 56 | this.UpdateBoidColor(); 57 | } 58 | 59 | public BoidCompute GetComputeShaderData() 60 | { 61 | return new BoidCompute 62 | { 63 | velocity = this.velocity, 64 | position = transform.position, 65 | separationVelocity = Vector3.zero, 66 | alignmentVelocity = Vector3.zero, 67 | cohesionVelocity = Vector3.zero, 68 | }; 69 | } 70 | 71 | public void UpdateLocalScale() 72 | { 73 | transform.localScale = new Vector3( 74 | this.boidSettings.boidScale, 75 | this.boidSettings.boidScale, 76 | this.boidSettings.boidScale 77 | ); 78 | } 79 | 80 | float RandomRangeWithStep(float min, float max, float step) 81 | { 82 | float steps = Mathf.Floor((max - min) / step); 83 | int randomStepIndex = Random.Range(0, Mathf.FloorToInt(steps) + 1); 84 | float randomValue = min + randomStepIndex * step; 85 | return Mathf.Clamp(randomValue, min, max); 86 | } 87 | 88 | Color GetRandomizedColor() 89 | { 90 | float colorMultiplier = RandomRangeWithStep(0.7f, 0.9f, 0.05f); 91 | Color randomizedColor = boidSettings.boidColor * colorMultiplier; 92 | return randomizedColor; 93 | } 94 | 95 | public void UpdateBoidColor() 96 | { 97 | Color randomizedColor = GetRandomizedColor(); 98 | Transform child = gameObject.transform.GetChild(0); 99 | Material material = child.GetComponent().material; 100 | material.SetColor("_BoidColor", randomizedColor); 101 | material.color = randomizedColor; 102 | } 103 | 104 | void UpdateRotation() 105 | { 106 | Quaternion targetRotation = Quaternion.LookRotation(velocity); 107 | transform.rotation = Quaternion.Lerp( 108 | transform.rotation, 109 | targetRotation, 110 | boidSettings.rotationSpeed * Time.deltaTime 111 | ); 112 | } 113 | 114 | // public void UpdateBoidV0(List boids) 115 | // { 116 | // Vector3 separationVelocity = Separation(boids); 117 | // Vector3 alignmentVelocity = Alignment(boids); 118 | // Vector3 cohesionVelocity = Cohesion(boids); 119 | 120 | // velocity += separationVelocity; 121 | // velocity += alignmentVelocity; 122 | // velocity += cohesionVelocity; 123 | 124 | // ClampBoidVelocity(); 125 | // UpdatePosition(); 126 | // UpdateRotation(); 127 | // DrawDebugView(); 128 | // } 129 | 130 | public void UpdateBoidV1(List boids) 131 | { 132 | // this vector represents the cumulative direction the 133 | // currBoid should take if it wants to avoid otherBoids 134 | // inside of its separationRange 135 | Vector3 separationVelocity = Separation(boids); 136 | 137 | // this vector represents the cumulative direction of 138 | // the flock within the currBoid's alignmentRange 139 | Vector3 alignmentVelocity = Alignment(boids); 140 | 141 | // this vector represents the cumulative direction the 142 | // currBoid needs to travel if it wants to be at the 143 | // center of its flock mates 144 | Vector3 cohesionVelocity = Cohesion(boids); 145 | 146 | velocity += separationVelocity; 147 | velocity += alignmentVelocity; 148 | velocity += cohesionVelocity; 149 | 150 | ClampBoidVelocity(); 151 | UpdatePosition(); 152 | UpdateRotation(); 153 | DrawDebugView(); 154 | } 155 | 156 | // public (Vector3, Vector3, Vector3) PerformThreeActionsV0(List boids) 157 | // { 158 | // Vector3 separationVelocity = Vector3.zero; 159 | // Vector3 alignmentVelocity = Vector3.zero; 160 | // Vector3 cohesionVelocity = Vector3.zero; 161 | // int numOfBoidsToAvoid = 0; 162 | // int numOfBoidsToAlignWith = 0; 163 | // int numOfBoidsInFlock = 0; 164 | // Vector3 currBoidPosition = transform.position; 165 | // Vector3 positionToMoveTowards = Vector3.zero; 166 | // foreach (Boid otherBoid in boids) 167 | // { 168 | // if (ReferenceEquals(gameObject, otherBoid.gameObject)) 169 | // { 170 | // continue; 171 | // } 172 | // Vector3 otherBoidPosition = otherBoid.transform.position; 173 | // float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 174 | // // separation check 175 | // if (dist < boidSettings.separationRange) 176 | // { 177 | // Vector3 otherBoidToCurrBoid = currBoidPosition - otherBoidPosition; 178 | // Vector3 dirToTravel = otherBoidToCurrBoid.normalized; 179 | // dirToTravel /= dist; 180 | // separationVelocity += dirToTravel; 181 | // numOfBoidsToAvoid++; 182 | // } 183 | // // alignment check 184 | // if (dist < boidSettings.alignmentRange) 185 | // { 186 | // alignmentVelocity += otherBoid.velocity; 187 | // numOfBoidsToAlignWith++; 188 | // } 189 | // // cohesion check 190 | // if (dist < boidSettings.cohesionRange) 191 | // { 192 | // positionToMoveTowards += otherBoidPosition; 193 | // numOfBoidsInFlock++; 194 | // } 195 | // } 196 | // // separation check 197 | // if (numOfBoidsToAvoid != 0) 198 | // { 199 | // separationVelocity /= (float)numOfBoidsToAvoid; 200 | // separationVelocity *= boidSettings.separationFactor; 201 | // } 202 | // // alignment check 203 | // if (numOfBoidsToAlignWith != 0) 204 | // { 205 | // alignmentVelocity /= (float)numOfBoidsToAlignWith; 206 | // alignmentVelocity *= boidSettings.alignmentFactor; 207 | // } 208 | // // cohesion check 209 | // if (numOfBoidsInFlock != 0) 210 | // { 211 | // positionToMoveTowards /= (float)numOfBoidsInFlock; 212 | // Vector3 cohesionDirection = positionToMoveTowards - currBoidPosition; 213 | // cohesionDirection.Normalize(); 214 | // cohesionVelocity = cohesionDirection * boidSettings.cohesionFactor; 215 | // } 216 | // return (separationVelocity, alignmentVelocity, cohesionVelocity); 217 | // } 218 | 219 | public (Vector3, Vector3, Vector3) PerformThreeActions(List boids) 220 | { 221 | Vector3 separationVelocity = Vector3.zero; 222 | Vector3 alignmentVelocity = Vector3.zero; 223 | Vector3 cohesionVelocity = Vector3.zero; 224 | 225 | int numOfBoidsToAvoid = 0; 226 | int numOfBoidsToAlignWith = 0; 227 | int numOfBoidsInFlock = 0; 228 | Vector3 currBoidPosition = transform.position; 229 | // cohesion variable 230 | Vector3 positionToMoveTowards = Vector3.zero; 231 | 232 | foreach (Boid otherBoid in boids) 233 | { 234 | if (ReferenceEquals(gameObject, otherBoid.gameObject)) 235 | { 236 | continue; 237 | } 238 | 239 | Vector3 otherBoidPosition = otherBoid.transform.position; 240 | float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 241 | 242 | // separation check 243 | if (dist < boidSettings.separationRange) 244 | { 245 | Vector3 otherBoidToCurrBoid = currBoidPosition - otherBoidPosition; 246 | Vector3 dirToTravel = otherBoidToCurrBoid.normalized; 247 | dirToTravel /= dist; 248 | separationVelocity += dirToTravel; 249 | numOfBoidsToAvoid++; 250 | } 251 | 252 | // alignment check 253 | if (dist < boidSettings.alignmentRange) 254 | { 255 | alignmentVelocity += otherBoid.velocity; 256 | numOfBoidsToAlignWith++; 257 | } 258 | 259 | // cohesion check 260 | if (dist < boidSettings.cohesionRange) 261 | { 262 | // keep track of the positions of all otherBoids that are in 263 | // the currBoid's cohesionRange 264 | positionToMoveTowards += otherBoidPosition; 265 | numOfBoidsInFlock++; 266 | } 267 | } 268 | 269 | if (numOfBoidsToAvoid != 0) 270 | { 271 | separationVelocity /= (float)numOfBoidsToAvoid; 272 | // normalized values look less cool in the simulation 273 | // separationVelocity.Normalize(); 274 | separationVelocity *= boidSettings.separationFactor; 275 | } 276 | 277 | if (numOfBoidsToAlignWith != 0) 278 | { 279 | alignmentVelocity /= (float)numOfBoidsToAlignWith; 280 | // normalized values look less cool in the simulation 281 | // alignmentVelocity.Normalize(); 282 | alignmentVelocity *= boidSettings.alignmentFactor; 283 | } 284 | 285 | if (numOfBoidsInFlock != 0) 286 | { 287 | positionToMoveTowards /= (float)numOfBoidsInFlock; 288 | Vector3 cohesionDirection = positionToMoveTowards - currBoidPosition; 289 | cohesionDirection.Normalize(); 290 | cohesionVelocity = cohesionDirection * boidSettings.cohesionFactor; 291 | } 292 | 293 | return (separationVelocity, alignmentVelocity, cohesionVelocity); 294 | } 295 | 296 | public void UpdateBoidV2(List boids) 297 | { 298 | (Vector3 separationVelocity, Vector3 alignmentVelocity, Vector3 cohesionVelocity) = 299 | PerformThreeActions(boids); 300 | 301 | velocity += separationVelocity; 302 | velocity += alignmentVelocity; 303 | velocity += cohesionVelocity; 304 | 305 | ClampBoidVelocity(); 306 | UpdatePosition(); 307 | UpdateRotation(); 308 | DrawDebugView(); 309 | } 310 | 311 | public void UpdateBoidV3( 312 | Vector3 separationVelocity, 313 | Vector3 alignmentVelocity, 314 | Vector3 cohesionVelocity 315 | ) 316 | { 317 | velocity += separationVelocity; 318 | velocity += alignmentVelocity; 319 | velocity += cohesionVelocity; 320 | 321 | ClampBoidVelocity(); 322 | UpdatePosition(); 323 | UpdateRotation(); 324 | DrawDebugView(); 325 | } 326 | 327 | public void ToggleDebugView() 328 | { 329 | debugViewEnabled = !debugViewEnabled; 330 | } 331 | 332 | public void DisableDebugView() 333 | { 334 | debugViewEnabled = false; 335 | } 336 | 337 | public void DrawDebugView() 338 | { 339 | if (!debugViewEnabled) 340 | { 341 | return; 342 | } 343 | 344 | Debug.DrawCircle(transform.position, boidSettings.separationRange, 24, Color.red); 345 | Debug.DrawCircle(transform.position, boidSettings.alignmentRange, 24, Color.green); 346 | Debug.DrawCircle(transform.position, boidSettings.cohesionRange, 24, Color.cyan); 347 | } 348 | 349 | // public Vector3 SeparationV0(List boids) 350 | // { 351 | // int numOfBoidsToAvoid = 0; 352 | // Vector3 separationVelocity = Vector3.zero; 353 | // Vector3 currBoidPosition = transform.position; 354 | // foreach (Boid otherBoid in boids) 355 | // { 356 | // if (ReferenceEquals(gameObject, otherBoid.gameObject)) 357 | // { 358 | // continue; 359 | // } 360 | // Vector3 otherBoidPosition = otherBoid.transform.position; 361 | // float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 362 | // if (dist < boidSettings.separationRange) 363 | // { 364 | // Vector3 otherBoidToCurrBoid = currBoidPosition - otherBoidPosition; 365 | // Vector3 dirToTravel = otherBoidToCurrBoid.normalized; 366 | // Vector3 weightedVelocity = dirToTravel / dist; 367 | // separationVelocity += weightedVelocity; 368 | // numOfBoidsToAvoid++; 369 | // } 370 | // } 371 | // if (numOfBoidsToAvoid > 0) 372 | // { 373 | // separationVelocity /= (float)numOfBoidsToAvoid; 374 | // separationVelocity *= boidSettings.separationFactor; 375 | // } 376 | // return separationVelocity; 377 | // } 378 | 379 | public Vector3 Separation(List boids) 380 | { 381 | int numOfBoidsToAvoid = 0; 382 | Vector3 separationVelocity = Vector3.zero; 383 | Vector3 currBoidPosition = transform.position; 384 | 385 | foreach (Boid otherBoid in boids) 386 | { 387 | if (ReferenceEquals(gameObject, otherBoid.gameObject)) 388 | { 389 | continue; 390 | } 391 | 392 | Vector3 otherBoidPosition = otherBoid.transform.position; 393 | float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 394 | 395 | // check if the otherBoid is running too close to the currBoid 396 | if (dist < boidSettings.separationRange) 397 | { 398 | // this vector represents the direction the currBoid needs 399 | // to travel in order to avoid collision with the otherBoid 400 | Vector3 otherBoidToCurrBoid = currBoidPosition - otherBoidPosition; 401 | Vector3 dirToTravel = otherBoidToCurrBoid.normalized; 402 | 403 | // scale the direction based on how far the the other boid is 404 | // if one boid is closer than the other, then the closer boid 405 | // will be given more weight 406 | dirToTravel /= dist; 407 | 408 | // accumulate separation velocity 409 | separationVelocity += dirToTravel; 410 | 411 | // keep track of how many boids are in the separationRange 412 | numOfBoidsToAvoid++; 413 | } 414 | } 415 | 416 | if (numOfBoidsToAvoid == 0) 417 | { 418 | return Vector3.zero; 419 | } 420 | 421 | // scale velocity down based on number of boids in the separationRange 422 | separationVelocity /= (float)numOfBoidsToAvoid; 423 | 424 | // tune the velocity based on the customizable separationFactor 425 | separationVelocity *= boidSettings.separationFactor; 426 | 427 | return separationVelocity; 428 | } 429 | 430 | // Vector3 AlignmentV0(List boids) 431 | // { 432 | // int numOfBoidsToAlignWith = 0; 433 | // Vector3 alignmentVelocity = Vector3.zero; 434 | // Vector3 currBoidPosition = transform.position; 435 | // foreach (Boid otherBoid in boids) 436 | // { 437 | // if (ReferenceEquals(gameObject, otherBoid.gameObject)) 438 | // { 439 | // continue; 440 | // } 441 | // Vector3 otherBoidPosition = otherBoid.transform.position; 442 | // float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 443 | // if (dist < boidSettings.alignmentRange) 444 | // { 445 | // alignmentVelocity += otherBoid.velocity; 446 | // numOfBoidsToAlignWith++; 447 | // } 448 | // } 449 | // if (numOfBoidsToAlignWith > 0) 450 | // { 451 | // alignmentVelocity /= (float)numOfBoidsToAlignWith; 452 | // alignmentVelocity *= boidSettings.alignmentFactor; 453 | // } 454 | // return alignmentVelocity; 455 | // } 456 | 457 | Vector3 Alignment(List boids) 458 | { 459 | int numOfBoidsToAlignWith = 0; 460 | Vector3 alignmentVelocity = Vector3.zero; 461 | Vector3 currBoidPosition = transform.position; 462 | 463 | foreach (Boid otherBoid in boids) 464 | { 465 | if (ReferenceEquals(gameObject, otherBoid.gameObject)) 466 | { 467 | continue; 468 | } 469 | 470 | Vector3 otherBoidPosition = otherBoid.transform.position; 471 | float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 472 | 473 | // check if the otherBoid is within alignmentRange of the currBoid 474 | if (dist < boidSettings.alignmentRange) 475 | { 476 | // increment the alignmentVelocity based on the otherBoid's velocity 477 | alignmentVelocity += otherBoid.velocity; 478 | numOfBoidsToAlignWith++; 479 | } 480 | } 481 | 482 | if (numOfBoidsToAlignWith == 0) 483 | { 484 | return Vector3.zero; 485 | } 486 | 487 | // average the alignmentVelocity of all boids in the alignmentRange to 488 | // get a vector that represents the average direction of the flock 489 | alignmentVelocity /= (float)numOfBoidsToAlignWith; 490 | 491 | // align the boid based on a customized alignmentFactor variable 492 | // high alignmentFactor means the the boid's alignment vector 493 | // will heavily influence the cumulative direction of the boid 494 | alignmentVelocity *= boidSettings.alignmentFactor; 495 | return alignmentVelocity; 496 | } 497 | 498 | // Vector3 CohesionV0(List boids) 499 | // { 500 | // int numOfBoidsInFlock = 0; 501 | // Vector3 cohesionVelocity = Vector3.zero; 502 | // Vector3 positionToMoveTowards = Vector3.zero; 503 | // Vector3 currBoidPosition = transform.position; 504 | // foreach (Boid otherBoid in boids) 505 | // { 506 | // if (ReferenceEquals(gameObject, otherBoid.gameObject)) 507 | // { 508 | // continue; 509 | // } 510 | // Vector3 otherBoidPosition = otherBoid.transform.position; 511 | // float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 512 | // if (dist < boidSettings.cohesionRange) 513 | // { 514 | // positionToMoveTowards += otherBoidPosition; 515 | // numOfBoidsInFlock++; 516 | // } 517 | // } 518 | // if (numOfBoidsInFlock > 0) 519 | // { 520 | // positionToMoveTowards /= (float)numOfBoidsInFlock; 521 | // Vector3 cohesionDirection = positionToMoveTowards - currBoidPosition; 522 | // cohesionDirection.Normalize(); 523 | // cohesionVelocity = cohesionDirection * boidSettings.cohesionFactor; 524 | // } 525 | 526 | // return cohesionVelocity; 527 | // } 528 | 529 | Vector3 Cohesion(List boids) 530 | { 531 | int numOfBoidsInFlock = 0; 532 | Vector3 positionToMoveTowards = Vector3.zero; 533 | Vector3 currBoidPosition = transform.position; 534 | 535 | foreach (Boid otherBoid in boids) 536 | { 537 | if (ReferenceEquals(gameObject, otherBoid.gameObject)) 538 | { 539 | continue; 540 | } 541 | 542 | Vector3 otherBoidPosition = otherBoid.transform.position; 543 | float dist = Vector3.Distance(currBoidPosition, otherBoidPosition); 544 | 545 | if (dist < boidSettings.cohesionRange) 546 | { 547 | // keep track of the positions of all otherBoids that are in 548 | // the currBoid's cohesionRange 549 | positionToMoveTowards += otherBoidPosition; 550 | numOfBoidsInFlock++; 551 | } 552 | } 553 | 554 | if (numOfBoidsInFlock == 0) 555 | { 556 | return Vector3.zero; 557 | } 558 | 559 | // this represents the position that the currBoid needs to move towards 560 | // if it wants to be at the average position of its flock mates 561 | positionToMoveTowards /= (float)numOfBoidsInFlock; 562 | 563 | // cohesionDirection is the vector that points from the currBoid's position 564 | // to the center of the flock (which we just calculated) 565 | Vector3 cohesionDirection = positionToMoveTowards - currBoidPosition; 566 | 567 | // we normalize this vector because the distance can vary based on the cohesionRange 568 | cohesionDirection.Normalize(); 569 | 570 | // align the boid based on a customized cohesionFactor variable 571 | // a high cohesionFactor means the the boid will strongly move 572 | // towards the center of the flock 573 | Vector3 cohesionVelocity = cohesionDirection * boidSettings.cohesionFactor; 574 | return cohesionVelocity; 575 | } 576 | 577 | void ClampBoidVelocity() 578 | { 579 | Vector3 position = transform.position; 580 | Vector3 direction = velocity.normalized; 581 | float speed = velocity.magnitude; 582 | speed = Mathf.Clamp(speed, boidSettings.minSpeed, boidSettings.maxSpeed); 583 | velocity = direction * speed; 584 | } 585 | 586 | void UpdatePosition() 587 | { 588 | transform.position = transform.position + velocity * Time.deltaTime; 589 | 590 | // outside of the top boundary 591 | if (transform.position.z > boidSettings.mapHeight) 592 | { 593 | transform.position = new Vector3(transform.position.x, 0, -boidSettings.mapHeight); 594 | } 595 | 596 | // outside of the bottom boundary 597 | if (transform.position.z < -boidSettings.mapHeight) 598 | { 599 | transform.position = new Vector3(transform.position.x, 0, boidSettings.mapHeight); 600 | } 601 | 602 | // outside of the right boundary 603 | if (transform.position.x > boidSettings.mapWidth) 604 | { 605 | transform.position = new Vector3(-boidSettings.mapWidth, 0, transform.position.z); 606 | } 607 | 608 | // outside of the left boundary 609 | if (transform.position.x < -boidSettings.mapWidth) 610 | { 611 | transform.position = new Vector3(boidSettings.mapWidth, 0, transform.position.z); 612 | } 613 | } 614 | } 615 | --------------------------------------------------------------------------------