├── .gitignore ├── Assets ├── ArriveUnit2.cs ├── ArriveUnit2.cs.meta ├── AssetBookmark.meta ├── AssetBookmark │ ├── Editor.meta │ ├── Editor │ │ ├── FinishedScript.meta │ │ └── FinishedScript │ │ │ ├── AssetBookmarkFinGUI.cs │ │ │ └── AssetBookmarkFinGUI.cs.meta │ ├── Resources.meta │ └── Resources │ │ ├── ABGuiSkin.guiskin │ │ ├── ABGuiSkin.guiskin.meta │ │ ├── Art.meta │ │ ├── Art │ │ ├── LabelBG.png │ │ ├── LabelBG.png.meta │ │ ├── LabelBttn_Press.png │ │ ├── LabelBttn_Press.png.meta │ │ ├── removeBttn_Normal.png │ │ ├── removeBttn_Normal.png.meta │ │ ├── removeBttn_Press.png │ │ └── removeBttn_Press.png.meta │ │ ├── Data.txt │ │ └── Data.txt.meta ├── CameraMovement2.cs ├── CameraMovement2.cs.meta ├── ExampleClass.cs ├── ExampleClass.cs.meta ├── Examples.meta ├── Examples │ ├── Arrive 2.unity │ ├── Arrive 2.unity.meta │ ├── Arrive.unity │ ├── Arrive.unity.meta │ ├── CollisionAvoidance 2.unity │ ├── CollisionAvoidance 2.unity.meta │ ├── CollisionAvoidance.unity │ ├── CollisionAvoidance.unity.meta │ ├── Empty 2.unity │ ├── Empty 2.unity.meta │ ├── Empty.unity │ ├── Empty.unity.meta │ ├── Evade 2.unity │ ├── Evade 2.unity.meta │ ├── Evade.unity │ ├── Evade.unity.meta │ ├── Flee 2.unity │ ├── Flee 2.unity.meta │ ├── Flee.unity │ ├── Flee.unity.meta │ ├── Flocking.unity │ ├── Flocking.unity.meta │ ├── FollowPath 2.unity │ ├── FollowPath 2.unity.meta │ ├── FollowPath.unity │ ├── FollowPath.unity.meta │ ├── Hide 2.unity │ ├── Hide 2.unity.meta │ ├── Hide.unity │ ├── Hide.unity.meta │ ├── Interpose 2.unity │ ├── Interpose 2.unity.meta │ ├── Interpose.unity │ ├── Interpose.unity.meta │ ├── OffsetPursuit 2.unity │ ├── OffsetPursuit 2.unity.meta │ ├── OffsetPursuit.unity │ ├── OffsetPursuit.unity.meta │ ├── Pursue 2.unity │ ├── Pursue 2.unity.meta │ ├── Pursue.unity │ ├── Pursue.unity.meta │ ├── Seek 2.unity │ ├── Seek 2.unity.meta │ ├── Seek.unity │ ├── Seek.unity.meta │ ├── WallAvoidance1 2.unity │ ├── WallAvoidance1 2.unity.meta │ ├── WallAvoidance1.unity │ ├── WallAvoidance1.unity.meta │ ├── WallAvoidance2 2.unity │ ├── WallAvoidance2 2.unity.meta │ ├── WallAvoidance2.unity │ ├── WallAvoidance2.unity.meta │ ├── Wander 2.unity │ ├── Wander 2.unity.meta │ ├── Wander.unity │ └── Wander.unity.meta ├── Flee2.cs ├── Flee2.cs.meta ├── FleeUnit2.cs ├── FleeUnit2.cs.meta ├── InterposeUnit2.cs ├── InterposeUnit2.cs.meta ├── Pursue2.cs ├── Pursue2.cs.meta ├── PursueUnit2.cs ├── PursueUnit2.cs.meta ├── Seek2Unit.cs ├── Seek2Unit.cs.meta ├── SteeringBasics2.cs ├── SteeringBasics2.cs.meta ├── Test.cs ├── Test.cs.meta ├── WallAvoidance2.cs ├── WallAvoidance2.cs.meta ├── WallAvoidanceUnit2.cs ├── WallAvoidanceUnit2.cs.meta ├── Wander3.cs ├── Wander3.cs.meta ├── Wander3Unit.cs ├── Wander3Unit.cs.meta ├── Wander4.cs ├── Wander4.cs.meta ├── Wander4Unit.cs ├── Wander4Unit.cs.meta ├── unity-movement-ai.meta └── unity-movement-ai │ ├── Models.meta │ ├── Models │ ├── Materials.meta │ ├── Materials │ │ ├── Green.mat │ │ ├── Green.mat.meta │ │ ├── Lines.mat │ │ ├── Lines.mat.meta │ │ ├── Lines.shader │ │ ├── Lines.shader.meta │ │ ├── Red.mat │ │ ├── Red.mat.meta │ │ ├── unnamed.mat │ │ └── unnamed.mat.meta │ ├── unit.blend │ └── unit.blend.meta │ ├── Prefabs.meta │ ├── Prefabs │ ├── ArriveUnit.prefab │ ├── ArriveUnit.prefab.meta │ ├── ColAvoidUnit1.prefab │ ├── ColAvoidUnit1.prefab.meta │ ├── ColAvoidUnit2.prefab │ ├── ColAvoidUnit2.prefab.meta │ ├── EvadeUnit.prefab │ ├── EvadeUnit.prefab.meta │ ├── FleeUnit.prefab │ ├── FleeUnit.prefab.meta │ ├── FlockingUnit.prefab │ ├── FlockingUnit.prefab.meta │ ├── FollowPathUnit.prefab │ ├── FollowPathUnit.prefab.meta │ ├── HideUnit.prefab │ ├── HideUnit.prefab.meta │ ├── InterposeUnit.prefab │ ├── InterposeUnit.prefab.meta │ ├── Obstacle.prefab │ ├── Obstacle.prefab.meta │ ├── OffsetPursuitUnit.prefab │ ├── OffsetPursuitUnit.prefab.meta │ ├── PursueUnit.prefab │ ├── PursueUnit.prefab.meta │ ├── ScreenBoundary.prefab │ ├── ScreenBoundary.prefab.meta │ ├── SeekUnit.prefab │ ├── SeekUnit.prefab.meta │ ├── Spawner.prefab │ ├── Spawner.prefab.meta │ ├── WallAvoidanceUnit.prefab │ ├── WallAvoidanceUnit.prefab.meta │ ├── Wander1Unit.prefab │ ├── Wander1Unit.prefab.meta │ ├── Wander2Unit.prefab │ ├── Wander2Unit.prefab.meta │ ├── WanderAvoidUnit.prefab │ └── WanderAvoidUnit.prefab.meta │ ├── Scripts.meta │ └── Scripts │ ├── ArriveUnit.cs │ ├── ArriveUnit.cs.meta │ ├── Camera.meta │ ├── Camera │ ├── CameraMovement.cs │ ├── CameraMovement.cs.meta │ ├── InfiniteGrid.cs │ └── InfiniteGrid.cs.meta │ ├── ColAvoidUnit.cs │ ├── ColAvoidUnit.cs.meta │ ├── EvadeUnit.cs │ ├── EvadeUnit.cs.meta │ ├── FleeUnit.cs │ ├── FleeUnit.cs.meta │ ├── FlockingUnit.cs │ ├── FlockingUnit.cs.meta │ ├── FollowPathUnit.cs │ ├── FollowPathUnit.cs.meta │ ├── HideUnit.cs │ ├── HideUnit.cs.meta │ ├── InterposeUnit.cs │ ├── InterposeUnit.cs.meta │ ├── Movement.meta │ ├── Movement │ ├── Cohesion.cs │ ├── Cohesion.cs.meta │ ├── CollisionAvoidance.cs │ ├── CollisionAvoidance.cs.meta │ ├── Evade.cs │ ├── Evade.cs.meta │ ├── Flee.cs │ ├── Flee.cs.meta │ ├── FollowPath.cs │ ├── FollowPath.cs.meta │ ├── Hide.cs │ ├── Hide.cs.meta │ ├── LinePath.cs │ ├── LinePath.cs.meta │ ├── NearSensor.cs │ ├── NearSensor.cs.meta │ ├── OffsetPursuit.cs │ ├── OffsetPursuit.cs.meta │ ├── Pursue.cs │ ├── Pursue.cs.meta │ ├── Separation.cs │ ├── Separation.cs.meta │ ├── SteeringBasics.cs │ ├── SteeringBasics.cs.meta │ ├── VelocityMatch.cs │ ├── VelocityMatch.cs.meta │ ├── WallAvoidance.cs │ ├── WallAvoidance.cs.meta │ ├── Wander1.cs │ ├── Wander1.cs.meta │ ├── Wander2.cs │ └── Wander2.cs.meta │ ├── OffsetPursuitUnit.cs │ ├── OffsetPursuitUnit.cs.meta │ ├── PursueUnit.cs │ ├── PursueUnit.cs.meta │ ├── ScreenBoundary.cs │ ├── ScreenBoundary.cs.meta │ ├── SeekUnit.cs │ ├── SeekUnit.cs.meta │ ├── Spawner.cs │ ├── Spawner.cs.meta │ ├── WallAvoidanceUnit.cs │ ├── WallAvoidanceUnit.cs.meta │ ├── Wander1Unit.cs │ ├── Wander1Unit.cs.meta │ ├── Wander2Unit.cs │ ├── Wander2Unit.cs.meta │ ├── WanderAvoidUnit.cs │ └── WanderAvoidUnit.cs.meta ├── LICENSE.md ├── PreviewImages ├── arrive.gif ├── colAvoid.gif ├── evade.gif ├── flocking.gif ├── followPath.gif ├── hide.gif ├── interpose.gif ├── offsetPursuit.gif ├── pursue.gif ├── wallAvoid.gif └── wander.gif ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset ├── UnityAnalyticsManager.asset └── UnityConnectSettings.asset ├── README.md └── unity-movement-ai.unitypackage /.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | Temp/ 5 | Library/ 6 | 7 | # ===================================== # 8 | # Visual Studio / MonoDevelop generated # 9 | # ===================================== # 10 | ExportedObj/ 11 | obj/ 12 | *.svd 13 | *.userprefs 14 | /*.csproj 15 | *.pidb 16 | *.suo 17 | /*.sln 18 | *.user 19 | *.unityproj 20 | *.booproj 21 | 22 | # ============ # 23 | # OS generated # 24 | # ============ # 25 | .DS_Store 26 | .DS_Store? 27 | ._* 28 | .Spotlight-V100 29 | .Trashes 30 | ehthumbs.db 31 | Thumbs.db 32 | 33 | # ============== # 34 | # My Own Ignores # 35 | # ============== # 36 | /Build/ -------------------------------------------------------------------------------- /Assets/ArriveUnit2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ArriveUnit2 : MonoBehaviour { 6 | 7 | public Vector3 targetPosition; 8 | 9 | private SteeringBasics2 steeringBasics; 10 | 11 | 12 | 13 | private void Start() 14 | { 15 | steeringBasics = GetComponent(); 16 | } 17 | 18 | private void Update() 19 | { 20 | // 计算线性加速度 21 | Vector3 accel = steeringBasics.Arrive(targetPosition); 22 | 23 | // 得到速度 24 | steeringBasics.Steer(accel); 25 | // 使当前的游戏对象的朝向 ,他要去的地方 26 | steeringBasics.LookWhereYoureGoing(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/ArriveUnit2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e231a11f53c2704bb6b4ae722664726 3 | timeCreated: 1506043204 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBookmark.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e196d53804644a94d957bad832fa5343 3 | folderAsset: yes 4 | timeCreated: 1480677551 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cfcaa19117048d48aadb34b835b05b5 3 | folderAsset: yes 4 | timeCreated: 1503490551 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Editor/FinishedScript.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77c50ac5c8b323949b0a09ad29671e0b 3 | folderAsset: yes 4 | timeCreated: 1503498503 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Editor/FinishedScript/AssetBookmarkFinGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2fed5fcaee84104fb29416244f7fb65 3 | timeCreated: 1503498490 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc0eadb8e3fc601418814a691b91ab91 3 | folderAsset: yes 4 | timeCreated: 1480546695 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/ABGuiSkin.guiskin.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c04fdb93e6b849f47acef936ceb18949 3 | timeCreated: 1480546716 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e73619022c973a54fb7dfca27f268814 3 | folderAsset: yes 4 | timeCreated: 1480546753 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/LabelBG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/Assets/AssetBookmark/Resources/Art/LabelBG.png -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/LabelBG.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d928dcadb9e658d459d581eff031004e 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: 0.25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 7 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 32 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | allowsAlphaSplitting: 0 39 | spriteMode: 0 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: 0.5, y: 0.5} 44 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | spriteTessellationDetail: -1 48 | textureType: 2 49 | buildTargetSettings: [] 50 | spriteSheet: 51 | serializedVersion: 2 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/LabelBttn_Press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/Assets/AssetBookmark/Resources/Art/LabelBttn_Press.png -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/LabelBttn_Press.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7211e8eb264861d45a7ba7b576c917b7 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: 0.25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 7 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 32 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | allowsAlphaSplitting: 0 39 | spriteMode: 0 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: 0.5, y: 0.5} 44 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | spriteTessellationDetail: -1 48 | textureType: 2 49 | buildTargetSettings: [] 50 | spriteSheet: 51 | serializedVersion: 2 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/removeBttn_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/Assets/AssetBookmark/Resources/Art/removeBttn_Normal.png -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/removeBttn_Normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15f4d56ec72a35b40be24cc67daa0d31 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: 0.25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 7 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 32 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | allowsAlphaSplitting: 0 39 | spriteMode: 0 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: 0.5, y: 0.5} 44 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | spriteTessellationDetail: -1 48 | textureType: 2 49 | buildTargetSettings: [] 50 | spriteSheet: 51 | serializedVersion: 2 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/removeBttn_Press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/Assets/AssetBookmark/Resources/Art/removeBttn_Press.png -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Art/removeBttn_Press.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37596bffd2b28514ab6393f3051c122a 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: 0.25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 7 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 32 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | allowsAlphaSplitting: 0 39 | spriteMode: 0 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: 0.5, y: 0.5} 44 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | spriteTessellationDetail: -1 48 | textureType: 2 49 | buildTargetSettings: [] 50 | spriteSheet: 51 | serializedVersion: 2 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Data.txt: -------------------------------------------------------------------------------- 1 | Assets/Examples/Interpose.unity,Interpose* -------------------------------------------------------------------------------- /Assets/AssetBookmark/Resources/Data.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0be540393dfb84f4682824b57361ba4f 3 | timeCreated: 1505970216 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CameraMovement2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class CameraMovement2 : MonoBehaviour { 6 | 7 | public Transform target; 8 | 9 | private Vector3 displacement; 10 | 11 | private void Start() 12 | { 13 | // 记住两个的位置差异 14 | displacement = transform.position - target.position; 15 | } 16 | 17 | private void LateUpdate() 18 | { 19 | if (!target) 20 | { 21 | transform.position = target.position + displacement; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/CameraMovement2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3124ef2455509e146ab64f4163cc2e0c 3 | timeCreated: 1506148781 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ExampleClass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using UnityEngine; 6 | using System.Collections; 7 | 8 | public class ExampleClass : MonoBehaviour 9 | { 10 | // When added to an object, draws colored rays from the 11 | // transform position. 12 | public int lineCount = 100; 13 | public float radius = 3.0f; 14 | 15 | static Material lineMaterial; 16 | static void CreateLineMaterial() 17 | { 18 | if (!lineMaterial) 19 | { 20 | // Unity has a built-in shader that is useful for drawing 21 | // simple colored things. 22 | Shader shader = Shader.Find("Hidden/Internal-Colored"); 23 | lineMaterial = new Material(shader); 24 | lineMaterial.hideFlags = HideFlags.HideAndDontSave; 25 | // Turn on alpha blending 26 | lineMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); 27 | lineMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); 28 | // Turn backface culling off 29 | lineMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off); 30 | // Turn off depth writes 31 | lineMaterial.SetInt("_ZWrite", 0); 32 | } 33 | } 34 | 35 | // Will be called after all regular rendering is done 36 | public void OnRenderObject() 37 | { 38 | CreateLineMaterial(); 39 | // Apply the line material 40 | lineMaterial.SetPass(0); 41 | 42 | GL.PushMatrix(); 43 | // Set transformation matrix for drawing to 44 | // match our transform 45 | GL.MultMatrix(transform.localToWorldMatrix); 46 | 47 | // Draw lines 48 | GL.Begin(GL.LINES); 49 | for (int i = 0; i < lineCount; ++i) 50 | { 51 | float a = i / (float)lineCount; 52 | float angle = a * Mathf.PI * 2; 53 | // Vertex colors change from red to green 54 | GL.Color(new Color(a, 1 - a, 0, 0.8F)); 55 | // One vertex at transform position 56 | GL.Vertex3(0, 0, 0); 57 | // Another vertex at edge of circle 58 | GL.Vertex3(Mathf.Cos(angle) * radius, Mathf.Sin(angle) * radius, 0); 59 | } 60 | GL.End(); 61 | GL.PopMatrix(); 62 | } 63 | } -------------------------------------------------------------------------------- /Assets/ExampleClass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 974f8fbcc96e8494fa30d08ac936d435 3 | timeCreated: 1506158883 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 475b7bd53297fab449aae3a8a551bedb 3 | folderAsset: yes 4 | timeCreated: 1445679897 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Examples/Arrive 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35e3bef5247340a429948872e06fe695 3 | timeCreated: 1445137318 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Arrive.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35e3bef5247340a429948872e06fe695 3 | timeCreated: 1445137318 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/CollisionAvoidance 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46dc14dba7131d14e90fbc4e25c64249 3 | timeCreated: 1445039827 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/CollisionAvoidance.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46dc14dba7131d14e90fbc4e25c64249 3 | timeCreated: 1445039827 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Empty 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8cc9e3bd54684af4ebbf6de6da93423e 3 | timeCreated: 1444773879 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Empty.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8cc9e3bd54684af4ebbf6de6da93423e 3 | timeCreated: 1444773879 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Evade 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a8d14936bcfd9b4db59dc4d477fbe0d 3 | timeCreated: 1445123886 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Evade.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a8d14936bcfd9b4db59dc4d477fbe0d 3 | timeCreated: 1445123886 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Flee 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 701b8f410c6884341a1573a98233af46 3 | timeCreated: 1445125003 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Flee.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 701b8f410c6884341a1573a98233af46 3 | timeCreated: 1445125003 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Flocking.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8ea7c2341ae6b043b33030f348b7cca 3 | timeCreated: 1445554724 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/FollowPath 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e2d0d463b7b48b4caa90f6d2c950a8b 3 | timeCreated: 1445039320 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/FollowPath.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e2d0d463b7b48b4caa90f6d2c950a8b 3 | timeCreated: 1445039320 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Hide 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74d165f473291874c8c7b957f91ba53b 3 | timeCreated: 1445210382 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Hide.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74d165f473291874c8c7b957f91ba53b 3 | timeCreated: 1445210382 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Interpose 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67df6bafc8996dc4f97f892bb0daf6ed 3 | timeCreated: 1445204252 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Interpose.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67df6bafc8996dc4f97f892bb0daf6ed 3 | timeCreated: 1445204252 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/OffsetPursuit 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d792e3cf59999a64db71abaeef39eecd 3 | timeCreated: 1445384586 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/OffsetPursuit.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d792e3cf59999a64db71abaeef39eecd 3 | timeCreated: 1445384586 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Pursue 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cb70af36da7fb94887e1f4adfcb3daa 3 | timeCreated: 1445138288 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Pursue.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cb70af36da7fb94887e1f4adfcb3daa 3 | timeCreated: 1445138288 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Seek 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca5d059be05447b40b29102013ff0048 3 | timeCreated: 1445140791 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Seek.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca5d059be05447b40b29102013ff0048 3 | timeCreated: 1445140791 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/WallAvoidance1 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59a8f3cb377a0564dbec58b7e73ec865 3 | timeCreated: 1444864391 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/WallAvoidance1.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59a8f3cb377a0564dbec58b7e73ec865 3 | timeCreated: 1444864391 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/WallAvoidance2 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0b1ed83d0bf0654b82c4cb0900df249 3 | timeCreated: 1445032162 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/WallAvoidance2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0b1ed83d0bf0654b82c4cb0900df249 3 | timeCreated: 1445032162 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Wander 2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fbe1f9442e6b044ab17e1da3b09b926 3 | timeCreated: 1445036106 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Wander.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fbe1f9442e6b044ab17e1da3b09b926 3 | timeCreated: 1445036106 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Flee2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class Flee2 : MonoBehaviour { 7 | 8 | // 跟目标保持的距离 9 | public float panicDist = 3.5f; 10 | 11 | // 是否开启快到目标时 减速 12 | public bool decelerateOnStop = true; 13 | 14 | public float maxAcceleration = 10f; 15 | 16 | // 跟 SteeringBasics2 中的意思类似 17 | public float timeToTarget = .1f; 18 | 19 | private Rigidbody rb; 20 | 21 | 22 | private void Start() 23 | { 24 | rb = GetComponent(); 25 | } 26 | 27 | public Vector3 GetSteering(Vector3 targetPosition) 28 | { 29 | // 得到方向 30 | Vector3 acceleration = transform.position - targetPosition; 31 | 32 | // 不需要逃离了 33 | if (acceleration.magnitude > panicDist) 34 | { 35 | // 如果我们要减速,就放慢速度 36 | if (decelerateOnStop && rb.velocity.magnitude > 0.001f) 37 | { 38 | 39 | if (acceleration.magnitude > maxAcceleration) 40 | { 41 | // 减速到0速 需要的时间 42 | acceleration = -rb.velocity / timeToTarget; 43 | 44 | } 45 | 46 | return acceleration; 47 | } 48 | else 49 | { 50 | rb.velocity = Vector2.zero; 51 | return Vector3.zero; 52 | } 53 | } 54 | 55 | // 以最大速度逃离 56 | return GiveMaxAccel(acceleration); 57 | } 58 | 59 | private Vector3 GiveMaxAccel(Vector3 v) 60 | { 61 | // 移除z 影响 62 | v.z = 0; 63 | 64 | v.Normalize(); 65 | 66 | v *= maxAcceleration; 67 | return v; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/Flee2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d378a6cdd3ad5234190317c2051ffd53 3 | timeCreated: 1506133423 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FleeUnit2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class FleeUnit2 : MonoBehaviour { 6 | 7 | public Transform target; 8 | 9 | public SteeringBasics2 steeringBasics; 10 | 11 | public Flee2 flee; 12 | 13 | private void Start() 14 | { 15 | steeringBasics = GetComponent(); 16 | 17 | flee = GetComponent(); 18 | } 19 | 20 | private void Update() 21 | { 22 | // 得到线性加速度 23 | Vector3 accel = flee.GetSteering(target.position); 24 | // 设置刚体速度 25 | steeringBasics.Steer(accel); 26 | // 设置朝向 27 | steeringBasics.LookWhereYoureGoing(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/FleeUnit2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37a539404a9d0ed468b251103269a4be 3 | timeCreated: 1506133395 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/InterposeUnit2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class InterposeUnit2 : MonoBehaviour { 6 | 7 | public Rigidbody target1; 8 | 9 | public Rigidbody target2; 10 | 11 | private SteeringBasics2 steeringBasics; 12 | 13 | private void Start() 14 | { 15 | steeringBasics = GetComponent(); 16 | } 17 | 18 | private void Update() 19 | { 20 | Vector3 accel = steeringBasics.Interpose(target1, target2); 21 | 22 | steeringBasics.Steer(accel); 23 | 24 | steeringBasics.LookWhereYoureGoing(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/InterposeUnit2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 789a98232b41c75428e350751fd08ffd 3 | timeCreated: 1506137066 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Pursue2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | [RequireComponent(typeof(SteeringBasics2))] 7 | public class Pursue2 : MonoBehaviour 8 | { 9 | // 未来预测的最大预测时间 10 | public float maxPrediction = 1f; 11 | 12 | private Rigidbody rb; 13 | 14 | private SteeringBasics2 steeringBasics; 15 | 16 | private void Start() 17 | { 18 | rb = GetComponent(); 19 | 20 | steeringBasics = GetComponent(); 21 | } 22 | 23 | 24 | internal Vector3 GetSteering(Rigidbody target) 25 | { 26 | // 计算到目标的距离 27 | Vector3 displacement = target.position - transform.position; 28 | float distance = displacement.magnitude; 29 | 30 | // 当前的速度 31 | float speed = rb.velocity.magnitude; 32 | 33 | // 计算预测时间 (不能让预测时间能跑的距离 超过当前的距离) 34 | float prediction; 35 | if (speed <= distance / maxPrediction) // (maxPrediction * speed <= distance ) 36 | { 37 | prediction = maxPrediction; 38 | } 39 | else 40 | { 41 | prediction = distance / speed; 42 | } 43 | 44 | // 目标 : 在目标位置基础上添加预测的部分 45 | Vector3 explicitTarget = target.position + target.velocity * prediction; 46 | 47 | return steeringBasics.Seek(explicitTarget); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/Pursue2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f6a8d8ef3cc4ae47a9b04cb41b5f180 3 | timeCreated: 1506125398 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/PursueUnit2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class PursueUnit2 : MonoBehaviour { 6 | // 得到目标位置 和 当前速度 7 | public Rigidbody target; 8 | 9 | // 组件 10 | private Pursue2 pursue; 11 | 12 | private SteeringBasics2 steeringBasics; 13 | 14 | private void Start() 15 | { 16 | steeringBasics = GetComponent(); 17 | pursue = GetComponent(); 18 | } 19 | 20 | private void Update() 21 | { 22 | // 得到线性加速度 23 | Vector3 accel = pursue.GetSteering(target); 24 | 25 | // 设置刚体速度 26 | steeringBasics.Steer(accel); 27 | 28 | // 朝向 29 | steeringBasics.LookWhereYoureGoing(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/PursueUnit2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 270d1e22271dec24c932508516f397aa 3 | timeCreated: 1506125409 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Seek2Unit.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Seek2Unit : MonoBehaviour 6 | { 7 | 8 | public Transform target; 9 | 10 | private SteeringBasics2 steeringBasics2; 11 | 12 | private void Start() 13 | { 14 | steeringBasics2 = GetComponent(); 15 | } 16 | 17 | private void Update() 18 | { 19 | var accel = steeringBasics2.Seek(target.position); 20 | 21 | steeringBasics2.Steer(accel); 22 | steeringBasics2.LookWhereYoureGoing(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/Seek2Unit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a274ddf396f1494fae7e5816a82de52 3 | timeCreated: 1506055736 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteeringBasics2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | 7 | [RequireComponent(typeof(Rigidbody))] 8 | public class SteeringBasics2 : MonoBehaviour { 9 | 10 | public float maxVelocity = 3.5f; 11 | /* The maximum acceleration */ 12 | public float maxAcceleration = 10f; 13 | /* The radius from the target that means we are close enough and have arrived */ 14 | public float targetRadius = 0.005f; 15 | 16 | /* The radius from the target where we start to slow down */ 17 | public float slowRadius = 1f; 18 | /* The time in which we want to achieve the targetSpeed */ 19 | public float timeToTarget = 0.1f; 20 | 21 | public float turnSpeed = 20f; 22 | 23 | private Rigidbody rb; 24 | 25 | public bool smoothing = true; 26 | public int numSamplesForSmoothing = 5; 27 | private Queue velocitySamples = new Queue(); 28 | 29 | void Start() 30 | { 31 | rb = GetComponent(); 32 | } 33 | 34 | public Vector3 Interpose(Rigidbody target1, Rigidbody target2) 35 | { 36 | Vector3 midPoint = (target1.position + target2.position) / 2; 37 | 38 | // 到达 他俩中间需要的时间 39 | float timeToReachMidPoint = Vector3.Distance(midPoint, transform.position)/ maxVelocity; 40 | 41 | // 预测 当我到达后他们的位置 42 | Vector3 futureTarget1Pos = target1.position + target1.velocity * timeToReachMidPoint; 43 | Vector3 futureTarget2Pos = target2.position + target2.velocity * timeToReachMidPoint; 44 | 45 | midPoint = (futureTarget1Pos + futureTarget2Pos) / 2; 46 | 47 | return Arrive(midPoint); 48 | } 49 | 50 | internal Vector3 Arrive(Vector3 targetPosition) 51 | { 52 | /* 得到 正确方向*/ 53 | Vector3 targetVelocity = targetPosition - transform.position; 54 | 55 | // 不让z轴变化 56 | targetVelocity.z = 0; 57 | 58 | /* 得到到目标的距离 */ 59 | float dist = targetVelocity.magnitude; 60 | 61 | /* 如果我们在停止的范围内, 那么停止(目标不是一个点,有范围的)*/ 62 | if (dist < targetRadius) 63 | { 64 | rb.velocity = Vector2.zero; 65 | return Vector2.zero; 66 | } 67 | 68 | /* 计算速度, 如果接近目标就减速, 否则就全速前进, 到目标就是0了 */ 69 | float targetSpeed; 70 | if (dist > slowRadius) 71 | { 72 | targetSpeed = maxVelocity; 73 | } 74 | else 75 | { 76 | targetSpeed = maxVelocity * (dist / slowRadius); 77 | } 78 | 79 | /* 实际的速度 = 方向 * 大小 */ 80 | targetVelocity.Normalize(); 81 | targetVelocity *= targetSpeed; 82 | 83 | // 计算我们想要的线性加速度(下一帧的速度 - 这一帧的速度) 84 | Vector3 acceleration = targetVelocity - new Vector3(rb.velocity.x, rb.velocity.y, 0); 85 | 86 | // 到达目标速度需要的时间。 默认是一秒,很长。 时间越短,加速度就要越大才行 87 | acceleration *= 1 / timeToTarget; 88 | Debug.Log(acceleration); 89 | 90 | 91 | /* 不要超过最大加速度 */ 92 | if (acceleration.magnitude > maxAcceleration) 93 | { 94 | acceleration.Normalize(); 95 | acceleration *= maxAcceleration; 96 | } 97 | 98 | return acceleration; 99 | } 100 | 101 | internal Vector3 Seek(Vector3 targetPosition) 102 | { 103 | return Seek(targetPosition, maxAcceleration); 104 | } 105 | 106 | private Vector3 Seek(Vector3 targetPosition, float maxSeekAccel) 107 | { 108 | // 得到方向 109 | Vector3 accelaration = targetPosition - transform.position; 110 | 111 | // z 不变 112 | accelaration.z = 0; 113 | 114 | accelaration.Normalize(); 115 | accelaration *= maxSeekAccel; 116 | 117 | return accelaration; 118 | } 119 | 120 | internal void Steer(Vector3 linearAcceleration) 121 | { 122 | rb.velocity += linearAcceleration * Time.deltaTime; 123 | 124 | // 不能超过最大速度 125 | if (rb.velocity.magnitude > maxVelocity) 126 | { 127 | rb.velocity = rb.velocity.normalized * maxVelocity; 128 | } 129 | } 130 | 131 | internal void LookWhereYoureGoing() 132 | { 133 | Vector2 direction = rb.velocity; 134 | 135 | if (smoothing) 136 | { 137 | if (velocitySamples.Count == numSamplesForSmoothing) 138 | { 139 | velocitySamples.Dequeue(); 140 | } 141 | 142 | velocitySamples.Enqueue(rb.velocity); 143 | 144 | direction = Vector2.zero; 145 | 146 | foreach (Vector2 v in velocitySamples) 147 | { 148 | direction += v; 149 | } 150 | 151 | direction /= velocitySamples.Count; 152 | } 153 | 154 | LookAtDirection(direction); 155 | } 156 | 157 | public void LookAtDirection(Vector2 direction) 158 | { 159 | direction.Normalize(); 160 | // If we have a non-zero direction then look towards that direciton otherwise do nothing 161 | if (direction.sqrMagnitude > 0.001f) 162 | { 163 | float toRotation = (Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg); 164 | float rotation = Mathf.LerpAngle(transform.rotation.eulerAngles.z, toRotation, Time.deltaTime * turnSpeed); 165 | transform.rotation = Quaternion.Euler(0, 0, rotation); 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /Assets/SteeringBasics2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a321203e11de234abeaa74dfc22a5d9 3 | timeCreated: 1506043133 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Test.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Profiling; 6 | 7 | public class Test : MonoBehaviour { 8 | 9 | // Use this for initialization 10 | void Start () { 11 | 12 | } 13 | 14 | // Update is called once per frame 15 | void Update () { 16 | 17 | } 18 | 19 | public bool IsAdjacent(Transform targetTrans) 20 | { 21 | using (var p = new ScopedProfiler("Adjacent")) 22 | { 23 | if (targetTrans == null) 24 | { 25 | return false; 26 | } 27 | 28 | for (int i = 0; i < targetTrans.childCount; i++) 29 | { 30 | if (targetTrans.GetChild(i).gameObject.name == "Text") 31 | { 32 | return true; 33 | } 34 | } 35 | 36 | return false; 37 | } 38 | 39 | } 40 | 41 | //public bool IsAdjacent(Transform targetTrans) 42 | //{ 43 | // Profiler.BeginSample("Adjacent"); 44 | // { 45 | // if (targetTrans == null) 46 | // { 47 | // Profiler.EndSample(); 48 | // return false; 49 | // } 50 | 51 | // for (int i = 0; i < targetTrans.childCount; i++) 52 | // { 53 | // if (targetTrans.GetChild(i).gameObject.name == "Text") 54 | // { 55 | // Profiler.EndSample(); 56 | // return true; 57 | // } 58 | // } 59 | // Profiler.EndSample(); 60 | // return false; 61 | // } 62 | //} 63 | } 64 | 65 | 66 | public struct ScopedProfiler : IDisposable 67 | { 68 | public ScopedProfiler(string name) 69 | { 70 | Profiler.BeginSample(name); 71 | } 72 | 73 | public ScopedProfiler(string name, UnityEngine.Object targetObject) 74 | { 75 | Profiler.BeginSample(name, targetObject); 76 | } 77 | 78 | void IDisposable.Dispose() 79 | { 80 | Profiler.EndSample(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Assets/Test.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf0db0979c7a0af49902bdcd336103ba 3 | timeCreated: 1504144593 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/WallAvoidance2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | [RequireComponent(typeof(SteeringBasics2))] 7 | public class WallAvoidance2 : MonoBehaviour 8 | { 9 | 10 | /* 前方射线应该延伸多远 */ 11 | public float mainWhiskerLen = 1.25f; 12 | 13 | /* 跟墙保持的距离 */ 14 | public float wallAvoidDistance = 0.5f; 15 | 16 | // 两边射线应该延伸多远 17 | public float sideWhiskerLen = 0.701f; 18 | 19 | // 两边射线的角度 20 | public float sideWhiskerAngle = 45f; 21 | 22 | public float maxAcceleration = 40f; 23 | 24 | // 组件 25 | private Rigidbody rb; 26 | private SteeringBasics steeringBasics; 27 | 28 | // Use this for initialization 29 | void Start() 30 | { 31 | rb = GetComponent(); 32 | steeringBasics = GetComponent(); 33 | } 34 | 35 | public Vector3 GetSteering() 36 | { 37 | return GetSteering(rb.velocity); 38 | } 39 | 40 | public Vector3 GetSteering(Vector3 facingDir) 41 | { 42 | Vector3 acceleration = Vector3.zero; 43 | 44 | /* 创建射线方向向量 */ 45 | Vector3[] rayDirs = new Vector3[3]; 46 | // 自己前进的方向 47 | rayDirs[0] = facingDir.normalized; 48 | 49 | // 返回弧度, 对边y/临边x 50 | float orientation = Mathf.Atan2(rb.velocity.y, rb.velocity.x); 51 | 52 | // 两边的射线方向 53 | rayDirs[1] = OrientationToVector(orientation + sideWhiskerAngle * Mathf.Deg2Rad); 54 | rayDirs[2] = OrientationToVector(orientation - sideWhiskerAngle * Mathf.Deg2Rad); 55 | 56 | RaycastHit hit; 57 | 58 | /* 如果没有碰撞,什么也不做 */ 59 | if (!FindObstacle(rayDirs, out hit)) 60 | { 61 | return acceleration; 62 | } 63 | 64 | /* 从墙上创建一个目标来 seek (这个方向和射线方向相反)*/ 65 | Vector3 targetPostition = hit.point + hit.normal * wallAvoidDistance; 66 | 67 | /* 如果速度和碰撞法线平行,则将目标向左或向右移动一点 (如果不矫正就会一直 垂直撞一个地方)*/ 68 | Vector3 cross = Vector3.Cross(rb.velocity, hit.normal); // 叉乘 判断两个向量是否平行 69 | // 点乘“·”计算得到的结果是一个标量; 平行向量 normalized的点乘 是 -1 或者 1, 垂直是0 70 | // 叉乘“×”得到的结果是一个垂直于原向量构成平面的向量。 平行向量的叉乘是零向量 71 | if (cross.magnitude < 0.005f) 72 | { 73 | targetPostition = targetPostition + new Vector3(-hit.normal.y, hit.normal.x, hit.normal.z); 74 | } 75 | 76 | // 返回最大加速度 77 | return steeringBasics.seek(targetPostition, maxAcceleration); 78 | } 79 | 80 | /* 将弧度 作为一个 单位向量返回 (极坐标公式)*/ 81 | private Vector3 OrientationToVector(float orientation) 82 | { 83 | return new Vector3(Mathf.Cos(orientation), Mathf.Sin(orientation), 0); 84 | } 85 | 86 | /// 87 | /// 多个射线, 检测是否发生碰撞 88 | /// 89 | /// 90 | /// 91 | /// 92 | private bool FindObstacle(Vector3[] rayDirs, out RaycastHit firstHit) 93 | { 94 | firstHit = new RaycastHit(); 95 | bool foundObs = false; 96 | 97 | for (int i = 0; i < rayDirs.Length; i++) 98 | { 99 | float rayDist = (i == 0) ? mainWhiskerLen : sideWhiskerLen; 100 | 101 | RaycastHit hit; 102 | 103 | if (Physics.Raycast(transform.position, rayDirs[i], out hit, rayDist)) 104 | { 105 | foundObs = true; 106 | firstHit = hit; 107 | break; 108 | } 109 | 110 | // 调试 111 | Debug.DrawLine(transform.position, transform.position + rayDirs[i] * rayDist); 112 | } 113 | 114 | return foundObs; 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /Assets/WallAvoidance2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb604942b8c735641be70bfa18b95616 3 | timeCreated: 1506146071 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/WallAvoidanceUnit2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class WallAvoidanceUnit2 : MonoBehaviour 6 | { 7 | 8 | // 编辑器下设置 路径 9 | public LinePath path; 10 | 11 | // 组件 12 | private SteeringBasics2 steeringBasics2; 13 | private WallAvoidance2 wallAvoidance2; 14 | private FollowPath followPath; 15 | 16 | private void Start() 17 | { 18 | path.calcDistances(); 19 | 20 | steeringBasics2 = GetComponent(); 21 | wallAvoidance2 = GetComponent(); 22 | followPath = GetComponent(); 23 | } 24 | 25 | private void Update() 26 | { 27 | // 到达终点了, 原路返回 28 | if (IsAtEndOfPath()) 29 | { 30 | path.reversePath(); 31 | } 32 | 33 | // 得到加速度 (要躲避墙) 34 | Vector3 accel = wallAvoidance2.GetSteering(); 35 | 36 | // 沿着路径走了 (约定没有碰撞时, 加速度为0 了) 37 | if (accel.magnitude < 0.005f) 38 | { 39 | accel = followPath.getSteering(path); 40 | } 41 | 42 | // 设置刚体 和 朝向 43 | steeringBasics2.Steer(accel); 44 | steeringBasics2.LookWhereYoureGoing(); 45 | 46 | // 调试 47 | path.draw(); 48 | } 49 | 50 | private bool IsAtEndOfPath() 51 | { 52 | return Vector3.Distance(path.endNode, transform.position) < followPath.stopRadius; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /Assets/WallAvoidanceUnit2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07520df7f6b7f21498b708b5de897fa7 3 | timeCreated: 1506146054 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Wander3.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class Wander3 : MonoBehaviour 7 | { 8 | 9 | public float wanderRadius = 1.2f; 10 | public float wanderDistance = 2f; 11 | 12 | // 随机的最大位移(1秒) 13 | public float wanderJitter = 40f; 14 | 15 | private Vector3 wanderTarget; 16 | 17 | private SteeringBasics2 steeringBasics2; 18 | 19 | private void Start() 20 | { 21 | // 随机一个 弧度 (角度的取值范围 0~360, 弧度范围 0~2π) 22 | float theta = Random.value * 2 * Mathf.PI; 23 | 24 | // 位置 向量(极坐标 得到) // x = rcos(θ), y = rsin(θ), 25 | wanderTarget = new Vector3(wanderRadius * Mathf.Cos(theta), 26 | wanderRadius * Mathf.Sin(theta), 0); 27 | 28 | steeringBasics2 = GetComponent(); 29 | } 30 | 31 | internal Vector3 GetSteering() 32 | { 33 | // 得到一帧时间的 最大位移 34 | float jitter = wanderJitter * Time.deltaTime; 35 | 36 | // 向目标的位置添加一个小的随机向量(每一帧都调整新的) 37 | wanderTarget += new Vector3(Random.Range(-1f, 1f) * jitter, 38 | Random.Range(-1f, 1f) * jitter, 0f); 39 | 40 | // 得到新的漫游圈 41 | wanderTarget.Normalize(); 42 | wanderTarget *= wanderRadius; 43 | 44 | // 得到目标位置, 在角色前方 基础上做一个偏移。 c = a + b , 就是对角线 45 | Vector3 targetPosition = transform.position + transform.right * wanderDistance + wanderTarget; 46 | 47 | // 为了调试 48 | Debug.DrawLine(transform.position, targetPosition); 49 | 50 | // 返回方向上的 最大加速度 51 | return steeringBasics2.Seek(targetPosition); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Assets/Wander3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b03975c03d26f4e409ebfd99710d6add 3 | timeCreated: 1506045424 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Wander3Unit.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Wander3Unit : MonoBehaviour 6 | { 7 | // 实际操作 Rigidbody 组件 8 | private SteeringBasics2 steeringBasics2; 9 | 10 | // 主要是得到加速度方向 11 | private Wander3 wander3; 12 | 13 | private void Start() 14 | { 15 | steeringBasics2 = GetComponent(); 16 | wander3 = GetComponent(); 17 | } 18 | 19 | private void Update() 20 | { 21 | // 得到加速度 22 | Vector3 accel = wander3.GetSteering(); 23 | 24 | // 设置刚体 和 方向 25 | steeringBasics2.Steer(accel); 26 | steeringBasics2.LookWhereYoureGoing(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/Wander3Unit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33395b105593125448b12959c22742d1 3 | timeCreated: 1506045445 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Wander4.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class Wander4 : MonoBehaviour 7 | { 8 | // 偏移量 9 | public float wanderOffset = 1.5f; 10 | // 半径 11 | public float wanderRadius = 4; 12 | // 比率 13 | public float wanderRate = .4f; 14 | 15 | private float wanderOrientation = 0; 16 | 17 | private SteeringBasics2 steeringBasics2; 18 | 19 | private void Start() 20 | { 21 | steeringBasics2 = GetComponent(); 22 | } 23 | 24 | internal Vector3 GetSteering() 25 | { 26 | // 当前角色的方向(弧度) 27 | float characterOrientation = transform.rotation.eulerAngles.z * Mathf.Deg2Rad; 28 | 29 | // 随机一个漫游方向(弧度) 30 | wanderOrientation += RandomBinomial() * wanderRate; 31 | 32 | // 目标方向结合(弧度), 就是在角色方向上的一个偏移 33 | float targetOrientation = wanderOrientation + characterOrientation; 34 | 35 | // 角色的前方(偏移量) 36 | Vector3 targetPosition = transform.position + (OrientationToVector(characterOrientation) * wanderOffset); 37 | 38 | // 得到目标位置 向量 c = a + b 就是对角线的方向 39 | targetPosition = targetPosition + (OrientationToVector(targetOrientation) * wanderRadius); 40 | 41 | // 调试 42 | Debug.DrawLine(transform.position, targetPosition); 43 | 44 | // 得到 最大加速度 45 | return steeringBasics2.Seek(targetPosition); 46 | } 47 | 48 | /*返回一个随机数介于-1和1。 值为零的可能性更大。*/ 49 | float RandomBinomial() 50 | { 51 | return Random.value - Random.value; 52 | } 53 | 54 | /* 返回方向的单位向量 */ 55 | Vector3 OrientationToVector(float orientation) 56 | { 57 | // 位置 向量(极坐标 得到) // x = rcos(θ), y = rsin(θ), 58 | return new Vector3(Mathf.Cos(orientation), Mathf.Sin(orientation), 0); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Assets/Wander4.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63364b92519796b4d9b0eb5b489a6756 3 | timeCreated: 1506050230 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Wander4Unit.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Wander4Unit : MonoBehaviour { 6 | 7 | // 实际操作 Rigidbody 组件 8 | private SteeringBasics2 steeringBasics2; 9 | 10 | // 主要是得到加速度方向 11 | private Wander4 wander4; 12 | 13 | private void Start() 14 | { 15 | steeringBasics2 = GetComponent(); 16 | wander4 = GetComponent(); 17 | } 18 | 19 | private void Update() 20 | { 21 | // 得到加速度 22 | Vector3 accel = wander4.GetSteering(); 23 | 24 | // 设置刚体 和 方向 25 | steeringBasics2.Steer(accel); 26 | steeringBasics2.LookWhereYoureGoing(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/Wander4Unit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5cdfb877841cde4e96903141405b906 3 | timeCreated: 1506050239 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46305bfe44baae240b621b83b8cb2312 3 | folderAsset: yes 4 | timeCreated: 1445682425 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1211219d01d31ff4e89d561924628d2f 3 | folderAsset: yes 4 | timeCreated: 1444774062 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13c72042cb219ef4c99362d22daf27c5 3 | folderAsset: yes 4 | timeCreated: 1444774090 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Green.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Green 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: _EMISSION 12 | m_LightmapFlags: 1 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.29803923, g: 0.6862745, b: 0.3137255, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Green.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5eff0f9175d0e054290206daa1eef80e 3 | timeCreated: 1445373227 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Lines.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Lines 10 | m_Shader: {fileID: 4800000, guid: 8ee66983680df0641839e93f4dc445f4, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_CustomRenderQueue: 2000 14 | stringTagMap: {} 15 | m_SavedProperties: 16 | serializedVersion: 2 17 | m_TexEnvs: {} 18 | m_Floats: {} 19 | m_Colors: 20 | data: 21 | first: 22 | name: _Color 23 | second: {r: 0, g: 0, b: 0, a: 1} 24 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Lines.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68454679857835641ae4595960001fbf 3 | timeCreated: 1445452144 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Lines.shader: -------------------------------------------------------------------------------- 1 | Shader "Lines/Colored Blended" { 2 | Properties { _Color ("Main Color", Color) = (0, 0, 0, 1) } 3 | 4 | SubShader { 5 | Pass { 6 | Blend SrcAlpha OneMinusSrcAlpha 7 | ZWrite Off Cull Off Fog { Mode Off } 8 | Color[_Color] 9 | BindChannels { 10 | Bind "vertex", vertex Bind "color", color 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Lines.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ee66983680df0641839e93f4dc445f4 3 | timeCreated: 1445451002 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Red.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Red 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: _EMISSION 12 | m_LightmapFlags: 1 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.95686275, g: 0.2627451, b: 0.21176471, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/Red.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f2d6f225d44e744dbbc449e44aa41fc 3 | timeCreated: 1445373168 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/unnamed.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: unnamed 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: _EMISSION 12 | m_LightmapFlags: 1 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.8, g: 0.8, b: 0.8, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/Materials/unnamed.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91a6a98d47f55e347a20c2dadf7a8b73 3 | timeCreated: 1444774090 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/unit.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/Assets/unity-movement-ai/Models/unit.blend -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Models/unit.blend.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb79ccf0fd6eb084587be081e0c6ddac 3 | timeCreated: 1444774090 4 | licenseType: Free 5 | ModelImporter: 6 | serializedVersion: 18 7 | fileIDToRecycleName: 8 | 100000: //RootNode 9 | 400000: //RootNode 10 | 2300000: //RootNode 11 | 3300000: //RootNode 12 | 4300000: Sphere 13 | 7400000: Default Take 14 | 9500000: //RootNode 15 | materials: 16 | importMaterials: 1 17 | materialName: 0 18 | materialSearch: 1 19 | animations: 20 | legacyGenerateAnimations: 4 21 | bakeSimulation: 0 22 | optimizeGameObjects: 0 23 | motionNodeName: 24 | animationImportErrors: 25 | animationImportWarnings: 26 | animationRetargetingWarnings: 27 | animationDoRetargetingWarnings: 0 28 | animationCompression: 1 29 | animationRotationError: .5 30 | animationPositionError: .5 31 | animationScaleError: .5 32 | animationWrapMode: 0 33 | extraExposedTransformPaths: [] 34 | clipAnimations: [] 35 | isReadable: 1 36 | meshes: 37 | lODScreenPercentages: [] 38 | globalScale: 1 39 | meshCompression: 0 40 | addColliders: 0 41 | importBlendShapes: 1 42 | swapUVChannels: 0 43 | generateSecondaryUV: 0 44 | useFileUnits: 1 45 | optimizeMeshForGPU: 1 46 | keepQuads: 0 47 | weldVertices: 1 48 | secondaryUVAngleDistortion: 8 49 | secondaryUVAreaDistortion: 15.000001 50 | secondaryUVHardAngle: 88 51 | secondaryUVPackMargin: 4 52 | useFileScale: 1 53 | tangentSpace: 54 | normalSmoothAngle: 60 55 | splitTangentsAcrossUV: 1 56 | normalImportMode: 0 57 | tangentImportMode: 1 58 | importAnimation: 1 59 | copyAvatar: 0 60 | humanDescription: 61 | human: [] 62 | skeleton: [] 63 | armTwist: .5 64 | foreArmTwist: .5 65 | upperLegTwist: .5 66 | legTwist: .5 67 | armStretch: .0500000007 68 | legStretch: .0500000007 69 | feetSpacing: 0 70 | rootMotionBoneName: 71 | hasTranslationDoF: 0 72 | lastHumanDescriptionAvatarSource: {instanceID: 0} 73 | animationType: 2 74 | humanoidOversampling: 1 75 | additionalBone: 0 76 | userData: 77 | assetBundleName: 78 | assetBundleVariant: 79 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7d91ea63fa61d54c92863fb2e902622 3 | folderAsset: yes 4 | timeCreated: 1444783773 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/ArriveUnit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &165344 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 444704} 11 | - 33: {fileID: 3325190} 12 | - 23: {fileID: 2344440} 13 | - 54: {fileID: 5442004} 14 | - 135: {fileID: 13518144} 15 | - 114: {fileID: 11439398} 16 | - 114: {fileID: 11492588} 17 | m_Layer: 0 18 | m_Name: ArriveUnit 19 | m_TagString: Untagged 20 | m_Icon: {fileID: 0} 21 | m_NavMeshLayer: 0 22 | m_StaticEditorFlags: 0 23 | m_IsActive: 1 24 | --- !u!4 &444704 25 | Transform: 26 | m_ObjectHideFlags: 1 27 | m_PrefabParentObject: {fileID: 0} 28 | m_PrefabInternal: {fileID: 100100000} 29 | m_GameObject: {fileID: 165344} 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 0, y: 0, z: 0} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_Children: [] 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | --- !u!23 &2344440 37 | MeshRenderer: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 165344} 42 | m_Enabled: 1 43 | m_CastShadows: 1 44 | m_ReceiveShadows: 1 45 | m_Materials: 46 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 47 | m_SubsetIndices: 48 | m_StaticBatchRoot: {fileID: 0} 49 | m_UseLightProbes: 1 50 | m_ReflectionProbeUsage: 1 51 | m_ProbeAnchor: {fileID: 0} 52 | m_ScaleInLightmap: 1 53 | m_PreserveUVs: 0 54 | m_ImportantGI: 0 55 | m_AutoUVMaxDistance: .5 56 | m_AutoUVMaxAngle: 89 57 | m_LightmapParameters: {fileID: 0} 58 | m_SortingLayerID: 0 59 | m_SortingOrder: 0 60 | --- !u!33 &3325190 61 | MeshFilter: 62 | m_ObjectHideFlags: 1 63 | m_PrefabParentObject: {fileID: 0} 64 | m_PrefabInternal: {fileID: 100100000} 65 | m_GameObject: {fileID: 165344} 66 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 67 | --- !u!54 &5442004 68 | Rigidbody: 69 | m_ObjectHideFlags: 1 70 | m_PrefabParentObject: {fileID: 0} 71 | m_PrefabInternal: {fileID: 100100000} 72 | m_GameObject: {fileID: 165344} 73 | serializedVersion: 2 74 | m_Mass: 1 75 | m_Drag: 0 76 | m_AngularDrag: .0500000007 77 | m_UseGravity: 0 78 | m_IsKinematic: 0 79 | m_Interpolate: 0 80 | m_Constraints: 120 81 | m_CollisionDetection: 0 82 | --- !u!114 &11439398 83 | MonoBehaviour: 84 | m_ObjectHideFlags: 1 85 | m_PrefabParentObject: {fileID: 0} 86 | m_PrefabInternal: {fileID: 100100000} 87 | m_GameObject: {fileID: 165344} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: ecfcf724a92030e4eb05c1a23e70116f, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | targetPosition: {x: -7, y: -4, z: 0} 94 | --- !u!114 &11492588 95 | MonoBehaviour: 96 | m_ObjectHideFlags: 1 97 | m_PrefabParentObject: {fileID: 0} 98 | m_PrefabInternal: {fileID: 100100000} 99 | m_GameObject: {fileID: 165344} 100 | m_Enabled: 1 101 | m_EditorHideFlags: 0 102 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 103 | m_Name: 104 | m_EditorClassIdentifier: 105 | maxVelocity: 3.5 106 | maxAcceleration: 10 107 | targetRadius: .00499999989 108 | slowRadius: 1 109 | timeToTarget: .100000001 110 | turnSpeed: 20 111 | smoothing: 1 112 | numSamplesForSmoothing: 5 113 | sepMaxAcceleration: 10 114 | sepThreshold: 1.66659999 115 | --- !u!135 &13518144 116 | SphereCollider: 117 | m_ObjectHideFlags: 1 118 | m_PrefabParentObject: {fileID: 0} 119 | m_PrefabInternal: {fileID: 100100000} 120 | m_GameObject: {fileID: 165344} 121 | m_Material: {fileID: 0} 122 | m_IsTrigger: 0 123 | m_Enabled: 1 124 | serializedVersion: 2 125 | m_Radius: .300000012 126 | m_Center: {x: 0, y: 0, z: -.300000012} 127 | --- !u!1001 &100100000 128 | Prefab: 129 | m_ObjectHideFlags: 1 130 | serializedVersion: 2 131 | m_Modification: 132 | m_TransformParent: {fileID: 0} 133 | m_Modifications: [] 134 | m_RemovedComponents: [] 135 | m_ParentPrefab: {fileID: 0} 136 | m_RootGameObject: {fileID: 165344} 137 | m_IsPrefabParent: 1 138 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/ArriveUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c3b01984c06a8a4789f8458da3c2a37 3 | timeCreated: 1445138170 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/ColAvoidUnit1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61b087f5f78e8d649a464e6025f7abc1 3 | timeCreated: 1445058739 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/ColAvoidUnit2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6f1274d3e6263641a5045bd41ecdb94 3 | timeCreated: 1445270928 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/EvadeUnit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &175194 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 465116} 11 | - 33: {fileID: 3343802} 12 | - 23: {fileID: 2326050} 13 | - 54: {fileID: 5409404} 14 | - 135: {fileID: 13544796} 15 | - 114: {fileID: 11497968} 16 | - 114: {fileID: 11495834} 17 | - 114: {fileID: 11446182} 18 | - 114: {fileID: 11433666} 19 | m_Layer: 0 20 | m_Name: EvadeUnit 21 | m_TagString: Untagged 22 | m_Icon: {fileID: 0} 23 | m_NavMeshLayer: 0 24 | m_StaticEditorFlags: 0 25 | m_IsActive: 1 26 | --- !u!4 &465116 27 | Transform: 28 | m_ObjectHideFlags: 1 29 | m_PrefabParentObject: {fileID: 0} 30 | m_PrefabInternal: {fileID: 100100000} 31 | m_GameObject: {fileID: 175194} 32 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 33 | m_LocalPosition: {x: 0, y: 0, z: 0} 34 | m_LocalScale: {x: 1, y: 1, z: 1} 35 | m_Children: [] 36 | m_Father: {fileID: 0} 37 | m_RootOrder: 0 38 | --- !u!23 &2326050 39 | MeshRenderer: 40 | m_ObjectHideFlags: 1 41 | m_PrefabParentObject: {fileID: 0} 42 | m_PrefabInternal: {fileID: 100100000} 43 | m_GameObject: {fileID: 175194} 44 | m_Enabled: 1 45 | m_CastShadows: 1 46 | m_ReceiveShadows: 1 47 | m_Materials: 48 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 49 | m_SubsetIndices: 50 | m_StaticBatchRoot: {fileID: 0} 51 | m_UseLightProbes: 1 52 | m_ReflectionProbeUsage: 1 53 | m_ProbeAnchor: {fileID: 0} 54 | m_ScaleInLightmap: 1 55 | m_PreserveUVs: 0 56 | m_ImportantGI: 0 57 | m_AutoUVMaxDistance: .5 58 | m_AutoUVMaxAngle: 89 59 | m_LightmapParameters: {fileID: 0} 60 | m_SortingLayerID: 0 61 | m_SortingOrder: 0 62 | --- !u!33 &3343802 63 | MeshFilter: 64 | m_ObjectHideFlags: 1 65 | m_PrefabParentObject: {fileID: 0} 66 | m_PrefabInternal: {fileID: 100100000} 67 | m_GameObject: {fileID: 175194} 68 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 69 | --- !u!54 &5409404 70 | Rigidbody: 71 | m_ObjectHideFlags: 1 72 | m_PrefabParentObject: {fileID: 0} 73 | m_PrefabInternal: {fileID: 100100000} 74 | m_GameObject: {fileID: 175194} 75 | serializedVersion: 2 76 | m_Mass: 1 77 | m_Drag: 0 78 | m_AngularDrag: .0500000007 79 | m_UseGravity: 0 80 | m_IsKinematic: 0 81 | m_Interpolate: 0 82 | m_Constraints: 120 83 | m_CollisionDetection: 0 84 | --- !u!114 &11433666 85 | MonoBehaviour: 86 | m_ObjectHideFlags: 1 87 | m_PrefabParentObject: {fileID: 0} 88 | m_PrefabInternal: {fileID: 100100000} 89 | m_GameObject: {fileID: 175194} 90 | m_Enabled: 1 91 | m_EditorHideFlags: 0 92 | m_Script: {fileID: 11500000, guid: 52e7f349139dea54da032182166c26d8, type: 3} 93 | m_Name: 94 | m_EditorClassIdentifier: 95 | maxPrediction: 1 96 | --- !u!114 &11446182 97 | MonoBehaviour: 98 | m_ObjectHideFlags: 1 99 | m_PrefabParentObject: {fileID: 0} 100 | m_PrefabInternal: {fileID: 100100000} 101 | m_GameObject: {fileID: 175194} 102 | m_Enabled: 1 103 | m_EditorHideFlags: 0 104 | m_Script: {fileID: 11500000, guid: 9cdf64bcab4d4d8468c92f1bc4b23f7c, type: 3} 105 | m_Name: 106 | m_EditorClassIdentifier: 107 | panicDist: Infinity 108 | decelerateOnStop: 1 109 | maxAcceleration: 10 110 | timeToTarget: .100000001 111 | --- !u!114 &11495834 112 | MonoBehaviour: 113 | m_ObjectHideFlags: 1 114 | m_PrefabParentObject: {fileID: 0} 115 | m_PrefabInternal: {fileID: 100100000} 116 | m_GameObject: {fileID: 175194} 117 | m_Enabled: 1 118 | m_EditorHideFlags: 0 119 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 120 | m_Name: 121 | m_EditorClassIdentifier: 122 | maxVelocity: 3.5 123 | maxAcceleration: 10 124 | targetRadius: .00499999989 125 | slowRadius: 1 126 | timeToTarget: .100000001 127 | turnSpeed: 20 128 | smoothing: 1 129 | numSamplesForSmoothing: 5 130 | sepMaxAcceleration: 10 131 | sepThreshold: 1.66659999 132 | --- !u!114 &11497968 133 | MonoBehaviour: 134 | m_ObjectHideFlags: 1 135 | m_PrefabParentObject: {fileID: 0} 136 | m_PrefabInternal: {fileID: 100100000} 137 | m_GameObject: {fileID: 175194} 138 | m_Enabled: 1 139 | m_EditorHideFlags: 0 140 | m_Script: {fileID: 11500000, guid: b0a3e859ea8fe534488413270935c6c1, type: 3} 141 | m_Name: 142 | m_EditorClassIdentifier: 143 | target: {fileID: 0} 144 | --- !u!135 &13544796 145 | SphereCollider: 146 | m_ObjectHideFlags: 1 147 | m_PrefabParentObject: {fileID: 0} 148 | m_PrefabInternal: {fileID: 100100000} 149 | m_GameObject: {fileID: 175194} 150 | m_Material: {fileID: 0} 151 | m_IsTrigger: 0 152 | m_Enabled: 1 153 | serializedVersion: 2 154 | m_Radius: .300000012 155 | m_Center: {x: 0, y: 0, z: -.300000012} 156 | --- !u!1001 &100100000 157 | Prefab: 158 | m_ObjectHideFlags: 1 159 | serializedVersion: 2 160 | m_Modification: 161 | m_TransformParent: {fileID: 0} 162 | m_Modifications: [] 163 | m_RemovedComponents: [] 164 | m_ParentPrefab: {fileID: 0} 165 | m_RootGameObject: {fileID: 175194} 166 | m_IsPrefabParent: 1 167 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/EvadeUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5bb1fe20c939954ba720df0cb0be27c 3 | timeCreated: 1445188804 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/FleeUnit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &131706 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 481000} 11 | - 33: {fileID: 3314436} 12 | - 23: {fileID: 2387162} 13 | - 54: {fileID: 5411190} 14 | - 135: {fileID: 13568662} 15 | - 114: {fileID: 11404330} 16 | - 114: {fileID: 11441856} 17 | m_Layer: 0 18 | m_Name: FleeUnit 19 | m_TagString: Untagged 20 | m_Icon: {fileID: 0} 21 | m_NavMeshLayer: 0 22 | m_StaticEditorFlags: 0 23 | m_IsActive: 1 24 | --- !u!4 &481000 25 | Transform: 26 | m_ObjectHideFlags: 1 27 | m_PrefabParentObject: {fileID: 0} 28 | m_PrefabInternal: {fileID: 100100000} 29 | m_GameObject: {fileID: 131706} 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 0, y: 0, z: 0} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_Children: [] 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | --- !u!23 &2387162 37 | MeshRenderer: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 131706} 42 | m_Enabled: 1 43 | m_CastShadows: 1 44 | m_ReceiveShadows: 1 45 | m_Materials: 46 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 47 | m_SubsetIndices: 48 | m_StaticBatchRoot: {fileID: 0} 49 | m_UseLightProbes: 1 50 | m_ReflectionProbeUsage: 1 51 | m_ProbeAnchor: {fileID: 0} 52 | m_ScaleInLightmap: 1 53 | m_PreserveUVs: 0 54 | m_ImportantGI: 0 55 | m_AutoUVMaxDistance: .5 56 | m_AutoUVMaxAngle: 89 57 | m_LightmapParameters: {fileID: 0} 58 | m_SortingLayerID: 0 59 | m_SortingOrder: 0 60 | --- !u!33 &3314436 61 | MeshFilter: 62 | m_ObjectHideFlags: 1 63 | m_PrefabParentObject: {fileID: 0} 64 | m_PrefabInternal: {fileID: 100100000} 65 | m_GameObject: {fileID: 131706} 66 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 67 | --- !u!54 &5411190 68 | Rigidbody: 69 | m_ObjectHideFlags: 1 70 | m_PrefabParentObject: {fileID: 0} 71 | m_PrefabInternal: {fileID: 100100000} 72 | m_GameObject: {fileID: 131706} 73 | serializedVersion: 2 74 | m_Mass: 1 75 | m_Drag: 0 76 | m_AngularDrag: .0500000007 77 | m_UseGravity: 0 78 | m_IsKinematic: 0 79 | m_Interpolate: 0 80 | m_Constraints: 120 81 | m_CollisionDetection: 0 82 | --- !u!114 &11404330 83 | MonoBehaviour: 84 | m_ObjectHideFlags: 1 85 | m_PrefabParentObject: {fileID: 0} 86 | m_PrefabInternal: {fileID: 100100000} 87 | m_GameObject: {fileID: 131706} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: 55191c5ba3a442d4e8b1f817bdb15378, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | target: {fileID: 0} 94 | panicDist: 5 95 | --- !u!114 &11441856 96 | MonoBehaviour: 97 | m_ObjectHideFlags: 1 98 | m_PrefabParentObject: {fileID: 0} 99 | m_PrefabInternal: {fileID: 100100000} 100 | m_GameObject: {fileID: 131706} 101 | m_Enabled: 1 102 | m_EditorHideFlags: 0 103 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 104 | m_Name: 105 | m_EditorClassIdentifier: 106 | maxVelocity: 3.5 107 | maxAcceleration: 10 108 | targetRadius: .00499999989 109 | slowRadius: 1 110 | timeToTarget: .100000001 111 | turnSpeed: 20 112 | smoothing: 1 113 | numSamplesForSmoothing: 5 114 | sepMaxAcceleration: 10 115 | sepThreshold: 1.66659999 116 | --- !u!135 &13568662 117 | SphereCollider: 118 | m_ObjectHideFlags: 1 119 | m_PrefabParentObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 100100000} 121 | m_GameObject: {fileID: 131706} 122 | m_Material: {fileID: 0} 123 | m_IsTrigger: 0 124 | m_Enabled: 1 125 | serializedVersion: 2 126 | m_Radius: .300000012 127 | m_Center: {x: 0, y: 0, z: -.300000012} 128 | --- !u!1001 &100100000 129 | Prefab: 130 | m_ObjectHideFlags: 1 131 | serializedVersion: 2 132 | m_Modification: 133 | m_TransformParent: {fileID: 0} 134 | m_Modifications: [] 135 | m_RemovedComponents: [] 136 | m_ParentPrefab: {fileID: 0} 137 | m_RootGameObject: {fileID: 131706} 138 | m_IsPrefabParent: 1 139 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/FleeUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28bd245136767a6439883098b9d5f339 3 | timeCreated: 1445136290 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/FlockingUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7811d047f013c5f43a36b27f05f17bbb 3 | timeCreated: 1445645982 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/FollowPathUnit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &199308 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 471744} 11 | - 33: {fileID: 3334030} 12 | - 23: {fileID: 2307250} 13 | - 54: {fileID: 5448904} 14 | - 135: {fileID: 13520100} 15 | - 114: {fileID: 11449618} 16 | - 114: {fileID: 11468718} 17 | - 114: {fileID: 11466984} 18 | m_Layer: 0 19 | m_Name: FollowPathUnit 20 | m_TagString: Untagged 21 | m_Icon: {fileID: 0} 22 | m_NavMeshLayer: 0 23 | m_StaticEditorFlags: 0 24 | m_IsActive: 1 25 | --- !u!4 &471744 26 | Transform: 27 | m_ObjectHideFlags: 1 28 | m_PrefabParentObject: {fileID: 0} 29 | m_PrefabInternal: {fileID: 100100000} 30 | m_GameObject: {fileID: 199308} 31 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 32 | m_LocalPosition: {x: 0, y: 0, z: 0} 33 | m_LocalScale: {x: 1, y: 1, z: 1} 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_RootOrder: 0 37 | --- !u!23 &2307250 38 | MeshRenderer: 39 | m_ObjectHideFlags: 1 40 | m_PrefabParentObject: {fileID: 0} 41 | m_PrefabInternal: {fileID: 100100000} 42 | m_GameObject: {fileID: 199308} 43 | m_Enabled: 1 44 | m_CastShadows: 1 45 | m_ReceiveShadows: 1 46 | m_Materials: 47 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 48 | m_SubsetIndices: 49 | m_StaticBatchRoot: {fileID: 0} 50 | m_UseLightProbes: 1 51 | m_ReflectionProbeUsage: 1 52 | m_ProbeAnchor: {fileID: 0} 53 | m_ScaleInLightmap: 1 54 | m_PreserveUVs: 0 55 | m_ImportantGI: 0 56 | m_AutoUVMaxDistance: .5 57 | m_AutoUVMaxAngle: 89 58 | m_LightmapParameters: {fileID: 0} 59 | m_SortingLayerID: 0 60 | m_SortingOrder: 0 61 | --- !u!33 &3334030 62 | MeshFilter: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 199308} 67 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 68 | --- !u!54 &5448904 69 | Rigidbody: 70 | m_ObjectHideFlags: 1 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | m_GameObject: {fileID: 199308} 74 | serializedVersion: 2 75 | m_Mass: 1 76 | m_Drag: 0 77 | m_AngularDrag: .0500000007 78 | m_UseGravity: 0 79 | m_IsKinematic: 0 80 | m_Interpolate: 0 81 | m_Constraints: 120 82 | m_CollisionDetection: 0 83 | --- !u!114 &11449618 84 | MonoBehaviour: 85 | m_ObjectHideFlags: 1 86 | m_PrefabParentObject: {fileID: 0} 87 | m_PrefabInternal: {fileID: 100100000} 88 | m_GameObject: {fileID: 199308} 89 | m_Enabled: 1 90 | m_EditorHideFlags: 0 91 | m_Script: {fileID: 11500000, guid: d127f162cb2d3b34784df7d7696be4e0, type: 3} 92 | m_Name: 93 | m_EditorClassIdentifier: 94 | path: 95 | nodes: 96 | - {x: -3, y: .5, z: 0} 97 | - {x: 5, y: 3.5, z: 0} 98 | --- !u!114 &11466984 99 | MonoBehaviour: 100 | m_ObjectHideFlags: 1 101 | m_PrefabParentObject: {fileID: 0} 102 | m_PrefabInternal: {fileID: 100100000} 103 | m_GameObject: {fileID: 199308} 104 | m_Enabled: 1 105 | m_EditorHideFlags: 0 106 | m_Script: {fileID: 11500000, guid: 049423ef460e2524186c56ba0e274368, type: 3} 107 | m_Name: 108 | m_EditorClassIdentifier: 109 | stopRadius: .00499999989 110 | pathOffset: .709999979 111 | pathDirection: 1 112 | --- !u!114 &11468718 113 | MonoBehaviour: 114 | m_ObjectHideFlags: 1 115 | m_PrefabParentObject: {fileID: 0} 116 | m_PrefabInternal: {fileID: 100100000} 117 | m_GameObject: {fileID: 199308} 118 | m_Enabled: 1 119 | m_EditorHideFlags: 0 120 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 121 | m_Name: 122 | m_EditorClassIdentifier: 123 | maxVelocity: 3.5 124 | maxAcceleration: 10 125 | targetRadius: .00499999989 126 | slowRadius: 1 127 | timeToTarget: .100000001 128 | turnSpeed: 20 129 | smoothing: 1 130 | numSamplesForSmoothing: 5 131 | sepMaxAcceleration: 10 132 | sepThreshold: 1.66659999 133 | collAvoidRadius: .5 134 | --- !u!135 &13520100 135 | SphereCollider: 136 | m_ObjectHideFlags: 1 137 | m_PrefabParentObject: {fileID: 0} 138 | m_PrefabInternal: {fileID: 100100000} 139 | m_GameObject: {fileID: 199308} 140 | m_Material: {fileID: 0} 141 | m_IsTrigger: 0 142 | m_Enabled: 1 143 | serializedVersion: 2 144 | m_Radius: .300000012 145 | m_Center: {x: 0, y: 0, z: -.300000012} 146 | --- !u!1001 &100100000 147 | Prefab: 148 | m_ObjectHideFlags: 1 149 | serializedVersion: 2 150 | m_Modification: 151 | m_TransformParent: {fileID: 0} 152 | m_Modifications: 153 | - target: {fileID: 0} 154 | propertyPath: m_Constraints 155 | value: 120 156 | objectReference: {fileID: 0} 157 | m_RemovedComponents: [] 158 | m_ParentPrefab: {fileID: 0} 159 | m_RootGameObject: {fileID: 199308} 160 | m_IsPrefabParent: 1 161 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/FollowPathUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b8141dc3c6e4cb49b4cf7b795ca5d74 3 | timeCreated: 1444783790 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/HideUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 169903cbb559e444f97e4606acc79194 3 | timeCreated: 1445373002 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/InterposeUnit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &118818 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 494964} 11 | - 33: {fileID: 3360540} 12 | - 23: {fileID: 2354476} 13 | - 54: {fileID: 5453142} 14 | - 135: {fileID: 13588998} 15 | - 114: {fileID: 11470476} 16 | - 114: {fileID: 11409158} 17 | m_Layer: 0 18 | m_Name: InterposeUnit 19 | m_TagString: Untagged 20 | m_Icon: {fileID: 0} 21 | m_NavMeshLayer: 0 22 | m_StaticEditorFlags: 0 23 | m_IsActive: 1 24 | --- !u!4 &494964 25 | Transform: 26 | m_ObjectHideFlags: 1 27 | m_PrefabParentObject: {fileID: 0} 28 | m_PrefabInternal: {fileID: 100100000} 29 | m_GameObject: {fileID: 118818} 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 0, y: 0, z: 0} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_Children: [] 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | --- !u!23 &2354476 37 | MeshRenderer: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 118818} 42 | m_Enabled: 1 43 | m_CastShadows: 1 44 | m_ReceiveShadows: 1 45 | m_Materials: 46 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 47 | m_SubsetIndices: 48 | m_StaticBatchRoot: {fileID: 0} 49 | m_UseLightProbes: 1 50 | m_ReflectionProbeUsage: 1 51 | m_ProbeAnchor: {fileID: 0} 52 | m_ScaleInLightmap: 1 53 | m_PreserveUVs: 0 54 | m_ImportantGI: 0 55 | m_AutoUVMaxDistance: .5 56 | m_AutoUVMaxAngle: 89 57 | m_LightmapParameters: {fileID: 0} 58 | m_SortingLayerID: 0 59 | m_SortingOrder: 0 60 | --- !u!33 &3360540 61 | MeshFilter: 62 | m_ObjectHideFlags: 1 63 | m_PrefabParentObject: {fileID: 0} 64 | m_PrefabInternal: {fileID: 100100000} 65 | m_GameObject: {fileID: 118818} 66 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 67 | --- !u!54 &5453142 68 | Rigidbody: 69 | m_ObjectHideFlags: 1 70 | m_PrefabParentObject: {fileID: 0} 71 | m_PrefabInternal: {fileID: 100100000} 72 | m_GameObject: {fileID: 118818} 73 | serializedVersion: 2 74 | m_Mass: 1 75 | m_Drag: 0 76 | m_AngularDrag: .0500000007 77 | m_UseGravity: 0 78 | m_IsKinematic: 0 79 | m_Interpolate: 0 80 | m_Constraints: 120 81 | m_CollisionDetection: 0 82 | --- !u!114 &11409158 83 | MonoBehaviour: 84 | m_ObjectHideFlags: 1 85 | m_PrefabParentObject: {fileID: 0} 86 | m_PrefabInternal: {fileID: 100100000} 87 | m_GameObject: {fileID: 118818} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | maxVelocity: 3.5 94 | maxAcceleration: 10 95 | targetRadius: .00499999989 96 | slowRadius: 1 97 | timeToTarget: .100000001 98 | turnSpeed: 20 99 | smoothing: 1 100 | numSamplesForSmoothing: 5 101 | sepMaxAcceleration: 10 102 | sepThreshold: 1.66659999 103 | --- !u!114 &11470476 104 | MonoBehaviour: 105 | m_ObjectHideFlags: 1 106 | m_PrefabParentObject: {fileID: 0} 107 | m_PrefabInternal: {fileID: 100100000} 108 | m_GameObject: {fileID: 118818} 109 | m_Enabled: 1 110 | m_EditorHideFlags: 0 111 | m_Script: {fileID: 11500000, guid: 3536641d912cf8b4c9d3c259b62f5e24, type: 3} 112 | m_Name: 113 | m_EditorClassIdentifier: 114 | target1: {fileID: 0} 115 | target2: {fileID: 0} 116 | --- !u!135 &13588998 117 | SphereCollider: 118 | m_ObjectHideFlags: 1 119 | m_PrefabParentObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 100100000} 121 | m_GameObject: {fileID: 118818} 122 | m_Material: {fileID: 0} 123 | m_IsTrigger: 0 124 | m_Enabled: 1 125 | serializedVersion: 2 126 | m_Radius: .300000012 127 | m_Center: {x: 0, y: 0, z: -.300000012} 128 | --- !u!1001 &100100000 129 | Prefab: 130 | m_ObjectHideFlags: 1 131 | serializedVersion: 2 132 | m_Modification: 133 | m_TransformParent: {fileID: 0} 134 | m_Modifications: [] 135 | m_RemovedComponents: [] 136 | m_ParentPrefab: {fileID: 0} 137 | m_RootGameObject: {fileID: 118818} 138 | m_IsPrefabParent: 1 139 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/InterposeUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de64d63e28828754fae81e255923d00c 3 | timeCreated: 1445205381 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Obstacle.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &161660 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 415264} 11 | - 33: {fileID: 3353948} 12 | - 135: {fileID: 13506922} 13 | - 23: {fileID: 2308278} 14 | - 54: {fileID: 5419392} 15 | m_Layer: 0 16 | m_Name: Obstacle 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &415264 23 | Transform: 24 | m_ObjectHideFlags: 1 25 | m_PrefabParentObject: {fileID: 0} 26 | m_PrefabInternal: {fileID: 100100000} 27 | m_GameObject: {fileID: 161660} 28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: .300000012} 31 | m_Children: [] 32 | m_Father: {fileID: 0} 33 | m_RootOrder: 0 34 | --- !u!23 &2308278 35 | MeshRenderer: 36 | m_ObjectHideFlags: 1 37 | m_PrefabParentObject: {fileID: 0} 38 | m_PrefabInternal: {fileID: 100100000} 39 | m_GameObject: {fileID: 161660} 40 | m_Enabled: 1 41 | m_CastShadows: 1 42 | m_ReceiveShadows: 1 43 | m_Materials: 44 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 45 | m_SubsetIndices: 46 | m_StaticBatchRoot: {fileID: 0} 47 | m_UseLightProbes: 1 48 | m_ReflectionProbeUsage: 1 49 | m_ProbeAnchor: {fileID: 0} 50 | m_ScaleInLightmap: 1 51 | m_PreserveUVs: 1 52 | m_ImportantGI: 0 53 | m_AutoUVMaxDistance: .5 54 | m_AutoUVMaxAngle: 89 55 | m_LightmapParameters: {fileID: 0} 56 | m_SortingLayerID: 0 57 | m_SortingOrder: 0 58 | --- !u!33 &3353948 59 | MeshFilter: 60 | m_ObjectHideFlags: 1 61 | m_PrefabParentObject: {fileID: 0} 62 | m_PrefabInternal: {fileID: 100100000} 63 | m_GameObject: {fileID: 161660} 64 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} 65 | --- !u!54 &5419392 66 | Rigidbody: 67 | m_ObjectHideFlags: 1 68 | m_PrefabParentObject: {fileID: 0} 69 | m_PrefabInternal: {fileID: 100100000} 70 | m_GameObject: {fileID: 161660} 71 | serializedVersion: 2 72 | m_Mass: 1 73 | m_Drag: 0 74 | m_AngularDrag: .0500000007 75 | m_UseGravity: 0 76 | m_IsKinematic: 1 77 | m_Interpolate: 0 78 | m_Constraints: 0 79 | m_CollisionDetection: 0 80 | --- !u!135 &13506922 81 | SphereCollider: 82 | m_ObjectHideFlags: 1 83 | m_PrefabParentObject: {fileID: 0} 84 | m_PrefabInternal: {fileID: 100100000} 85 | m_GameObject: {fileID: 161660} 86 | m_Material: {fileID: 0} 87 | m_IsTrigger: 0 88 | m_Enabled: 1 89 | serializedVersion: 2 90 | m_Radius: .5 91 | m_Center: {x: 0, y: 0, z: 0} 92 | --- !u!1001 &100100000 93 | Prefab: 94 | m_ObjectHideFlags: 1 95 | serializedVersion: 2 96 | m_Modification: 97 | m_TransformParent: {fileID: 0} 98 | m_Modifications: 99 | - target: {fileID: 0} 100 | propertyPath: m_LocalScale.z 101 | value: .300000012 102 | objectReference: {fileID: 0} 103 | m_RemovedComponents: [] 104 | m_ParentPrefab: {fileID: 0} 105 | m_RootGameObject: {fileID: 161660} 106 | m_IsPrefabParent: 1 107 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Obstacle.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42b9f0b5c3336af4eb6299b224c18f68 3 | timeCreated: 1445210771 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/OffsetPursuitUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85f9ae2daa0efae42a9814c8de2d0d2d 3 | timeCreated: 1445386547 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/PursueUnit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &130544 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 442860} 11 | - 33: {fileID: 3331680} 12 | - 23: {fileID: 2326942} 13 | - 54: {fileID: 5438218} 14 | - 135: {fileID: 13565114} 15 | - 114: {fileID: 11432080} 16 | - 114: {fileID: 11497850} 17 | - 114: {fileID: 11449512} 18 | m_Layer: 0 19 | m_Name: PursueUnit 20 | m_TagString: Untagged 21 | m_Icon: {fileID: 0} 22 | m_NavMeshLayer: 0 23 | m_StaticEditorFlags: 0 24 | m_IsActive: 1 25 | --- !u!4 &442860 26 | Transform: 27 | m_ObjectHideFlags: 1 28 | m_PrefabParentObject: {fileID: 0} 29 | m_PrefabInternal: {fileID: 100100000} 30 | m_GameObject: {fileID: 130544} 31 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 32 | m_LocalPosition: {x: 0, y: 0, z: 0} 33 | m_LocalScale: {x: 1, y: 1, z: 1} 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_RootOrder: 0 37 | --- !u!23 &2326942 38 | MeshRenderer: 39 | m_ObjectHideFlags: 1 40 | m_PrefabParentObject: {fileID: 0} 41 | m_PrefabInternal: {fileID: 100100000} 42 | m_GameObject: {fileID: 130544} 43 | m_Enabled: 1 44 | m_CastShadows: 1 45 | m_ReceiveShadows: 1 46 | m_Materials: 47 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 48 | m_SubsetIndices: 49 | m_StaticBatchRoot: {fileID: 0} 50 | m_UseLightProbes: 1 51 | m_ReflectionProbeUsage: 1 52 | m_ProbeAnchor: {fileID: 0} 53 | m_ScaleInLightmap: 1 54 | m_PreserveUVs: 0 55 | m_ImportantGI: 0 56 | m_AutoUVMaxDistance: .5 57 | m_AutoUVMaxAngle: 89 58 | m_LightmapParameters: {fileID: 0} 59 | m_SortingLayerID: 0 60 | m_SortingOrder: 0 61 | --- !u!33 &3331680 62 | MeshFilter: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 130544} 67 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 68 | --- !u!54 &5438218 69 | Rigidbody: 70 | m_ObjectHideFlags: 1 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | m_GameObject: {fileID: 130544} 74 | serializedVersion: 2 75 | m_Mass: 1 76 | m_Drag: 0 77 | m_AngularDrag: .0500000007 78 | m_UseGravity: 0 79 | m_IsKinematic: 0 80 | m_Interpolate: 0 81 | m_Constraints: 120 82 | m_CollisionDetection: 0 83 | --- !u!114 &11432080 84 | MonoBehaviour: 85 | m_ObjectHideFlags: 1 86 | m_PrefabParentObject: {fileID: 0} 87 | m_PrefabInternal: {fileID: 100100000} 88 | m_GameObject: {fileID: 130544} 89 | m_Enabled: 1 90 | m_EditorHideFlags: 0 91 | m_Script: {fileID: 11500000, guid: 28a5ea66325b4b34bb7fdd2c5706ca3e, type: 3} 92 | m_Name: 93 | m_EditorClassIdentifier: 94 | target: {fileID: 0} 95 | --- !u!114 &11449512 96 | MonoBehaviour: 97 | m_ObjectHideFlags: 1 98 | m_PrefabParentObject: {fileID: 0} 99 | m_PrefabInternal: {fileID: 100100000} 100 | m_GameObject: {fileID: 130544} 101 | m_Enabled: 1 102 | m_EditorHideFlags: 0 103 | m_Script: {fileID: 11500000, guid: e2da78e0f74f9cf449361cf180272705, type: 3} 104 | m_Name: 105 | m_EditorClassIdentifier: 106 | maxPrediction: 1 107 | --- !u!114 &11497850 108 | MonoBehaviour: 109 | m_ObjectHideFlags: 1 110 | m_PrefabParentObject: {fileID: 0} 111 | m_PrefabInternal: {fileID: 100100000} 112 | m_GameObject: {fileID: 130544} 113 | m_Enabled: 1 114 | m_EditorHideFlags: 0 115 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 116 | m_Name: 117 | m_EditorClassIdentifier: 118 | maxVelocity: 3.5 119 | maxAcceleration: 10 120 | targetRadius: .00499999989 121 | slowRadius: 1 122 | timeToTarget: .100000001 123 | turnSpeed: 20 124 | smoothing: 1 125 | numSamplesForSmoothing: 5 126 | sepMaxAcceleration: 10 127 | sepThreshold: 1.66659999 128 | --- !u!135 &13565114 129 | SphereCollider: 130 | m_ObjectHideFlags: 1 131 | m_PrefabParentObject: {fileID: 0} 132 | m_PrefabInternal: {fileID: 100100000} 133 | m_GameObject: {fileID: 130544} 134 | m_Material: {fileID: 0} 135 | m_IsTrigger: 0 136 | m_Enabled: 1 137 | serializedVersion: 2 138 | m_Radius: .300000012 139 | m_Center: {x: 0, y: 0, z: -.300000012} 140 | --- !u!1001 &100100000 141 | Prefab: 142 | m_ObjectHideFlags: 1 143 | serializedVersion: 2 144 | m_Modification: 145 | m_TransformParent: {fileID: 0} 146 | m_Modifications: 147 | - target: {fileID: 0} 148 | propertyPath: maxVelocity 149 | value: 4 150 | objectReference: {fileID: 0} 151 | m_RemovedComponents: [] 152 | m_ParentPrefab: {fileID: 0} 153 | m_RootGameObject: {fileID: 130544} 154 | m_IsPrefabParent: 1 155 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/PursueUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 877167d1f91274a4281ed4fe9864c393 3 | timeCreated: 1445188923 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/ScreenBoundary.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &160320 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 457112} 11 | - 33: {fileID: 3324950} 12 | - 65: {fileID: 6565720} 13 | - 114: {fileID: 11470440} 14 | m_Layer: 8 15 | m_Name: ScreenBoundary 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &457112 22 | Transform: 23 | m_ObjectHideFlags: 1 24 | m_PrefabParentObject: {fileID: 0} 25 | m_PrefabInternal: {fileID: 100100000} 26 | m_GameObject: {fileID: 160320} 27 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 28 | m_LocalPosition: {x: 0, y: 0, z: 0} 29 | m_LocalScale: {x: 1, y: 1, z: 4} 30 | m_Children: [] 31 | m_Father: {fileID: 0} 32 | m_RootOrder: 0 33 | --- !u!33 &3324950 34 | MeshFilter: 35 | m_ObjectHideFlags: 1 36 | m_PrefabParentObject: {fileID: 0} 37 | m_PrefabInternal: {fileID: 100100000} 38 | m_GameObject: {fileID: 160320} 39 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 40 | --- !u!65 &6565720 41 | BoxCollider: 42 | m_ObjectHideFlags: 1 43 | m_PrefabParentObject: {fileID: 0} 44 | m_PrefabInternal: {fileID: 100100000} 45 | m_GameObject: {fileID: 160320} 46 | m_Material: {fileID: 0} 47 | m_IsTrigger: 1 48 | m_Enabled: 1 49 | serializedVersion: 2 50 | m_Size: {x: 1, y: 1, z: 1} 51 | m_Center: {x: 0, y: 0, z: 0} 52 | --- !u!114 &11470440 53 | MonoBehaviour: 54 | m_ObjectHideFlags: 1 55 | m_PrefabParentObject: {fileID: 0} 56 | m_PrefabInternal: {fileID: 100100000} 57 | m_GameObject: {fileID: 160320} 58 | m_Enabled: 1 59 | m_EditorHideFlags: 0 60 | m_Script: {fileID: 11500000, guid: 69e649a4f3e436244b1498ab2c59107d, type: 3} 61 | m_Name: 62 | m_EditorClassIdentifier: 63 | --- !u!1001 &100100000 64 | Prefab: 65 | m_ObjectHideFlags: 1 66 | serializedVersion: 2 67 | m_Modification: 68 | m_TransformParent: {fileID: 0} 69 | m_Modifications: 70 | - target: {fileID: 0} 71 | propertyPath: m_Layer 72 | value: 8 73 | objectReference: {fileID: 0} 74 | m_RemovedComponents: [] 75 | m_ParentPrefab: {fileID: 0} 76 | m_RootGameObject: {fileID: 160320} 77 | m_IsPrefabParent: 1 78 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/ScreenBoundary.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fe3f13595b05354ab1b6bd1c710d777 3 | timeCreated: 1445037934 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/SeekUnit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &122656 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 469634} 11 | - 33: {fileID: 3361840} 12 | - 23: {fileID: 2383574} 13 | - 54: {fileID: 5427432} 14 | - 135: {fileID: 13592788} 15 | - 114: {fileID: 11418928} 16 | - 114: {fileID: 11414804} 17 | m_Layer: 0 18 | m_Name: SeekUnit 19 | m_TagString: Untagged 20 | m_Icon: {fileID: 0} 21 | m_NavMeshLayer: 0 22 | m_StaticEditorFlags: 0 23 | m_IsActive: 1 24 | --- !u!4 &469634 25 | Transform: 26 | m_ObjectHideFlags: 1 27 | m_PrefabParentObject: {fileID: 0} 28 | m_PrefabInternal: {fileID: 100100000} 29 | m_GameObject: {fileID: 122656} 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 0, y: 0, z: 0} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_Children: [] 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | --- !u!23 &2383574 37 | MeshRenderer: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 122656} 42 | m_Enabled: 1 43 | m_CastShadows: 1 44 | m_ReceiveShadows: 1 45 | m_Materials: 46 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 47 | m_SubsetIndices: 48 | m_StaticBatchRoot: {fileID: 0} 49 | m_UseLightProbes: 1 50 | m_ReflectionProbeUsage: 1 51 | m_ProbeAnchor: {fileID: 0} 52 | m_ScaleInLightmap: 1 53 | m_PreserveUVs: 0 54 | m_ImportantGI: 0 55 | m_AutoUVMaxDistance: .5 56 | m_AutoUVMaxAngle: 89 57 | m_LightmapParameters: {fileID: 0} 58 | m_SortingLayerID: 0 59 | m_SortingOrder: 0 60 | --- !u!33 &3361840 61 | MeshFilter: 62 | m_ObjectHideFlags: 1 63 | m_PrefabParentObject: {fileID: 0} 64 | m_PrefabInternal: {fileID: 100100000} 65 | m_GameObject: {fileID: 122656} 66 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 67 | --- !u!54 &5427432 68 | Rigidbody: 69 | m_ObjectHideFlags: 1 70 | m_PrefabParentObject: {fileID: 0} 71 | m_PrefabInternal: {fileID: 100100000} 72 | m_GameObject: {fileID: 122656} 73 | serializedVersion: 2 74 | m_Mass: 1 75 | m_Drag: 0 76 | m_AngularDrag: .0500000007 77 | m_UseGravity: 0 78 | m_IsKinematic: 0 79 | m_Interpolate: 0 80 | m_Constraints: 120 81 | m_CollisionDetection: 0 82 | --- !u!114 &11414804 83 | MonoBehaviour: 84 | m_ObjectHideFlags: 1 85 | m_PrefabParentObject: {fileID: 0} 86 | m_PrefabInternal: {fileID: 100100000} 87 | m_GameObject: {fileID: 122656} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | maxVelocity: 3.5 94 | maxAcceleration: 10 95 | targetRadius: .00499999989 96 | slowRadius: 1 97 | timeToTarget: .100000001 98 | turnSpeed: 20 99 | smoothing: 1 100 | numSamplesForSmoothing: 5 101 | sepMaxAcceleration: 10 102 | sepThreshold: 1.66659999 103 | --- !u!114 &11418928 104 | MonoBehaviour: 105 | m_ObjectHideFlags: 1 106 | m_PrefabParentObject: {fileID: 0} 107 | m_PrefabInternal: {fileID: 100100000} 108 | m_GameObject: {fileID: 122656} 109 | m_Enabled: 1 110 | m_EditorHideFlags: 0 111 | m_Script: {fileID: 11500000, guid: 4ae73ab1d415c7c4a9ffbd954f482d15, type: 3} 112 | m_Name: 113 | m_EditorClassIdentifier: 114 | target: {fileID: 0} 115 | --- !u!135 &13592788 116 | SphereCollider: 117 | m_ObjectHideFlags: 1 118 | m_PrefabParentObject: {fileID: 0} 119 | m_PrefabInternal: {fileID: 100100000} 120 | m_GameObject: {fileID: 122656} 121 | m_Material: {fileID: 0} 122 | m_IsTrigger: 0 123 | m_Enabled: 1 124 | serializedVersion: 2 125 | m_Radius: .300000012 126 | m_Center: {x: 0, y: 0, z: -.300000012} 127 | --- !u!1001 &100100000 128 | Prefab: 129 | m_ObjectHideFlags: 1 130 | serializedVersion: 2 131 | m_Modification: 132 | m_TransformParent: {fileID: 0} 133 | m_Modifications: [] 134 | m_RemovedComponents: [] 135 | m_ParentPrefab: {fileID: 0} 136 | m_RootGameObject: {fileID: 122656} 137 | m_IsPrefabParent: 1 138 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/SeekUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 500699f3ba0b7f0438e50d52a0fb3691 3 | timeCreated: 1445124924 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Spawner.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &105404 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 491568} 11 | - 114: {fileID: 11493774} 12 | m_Layer: 0 13 | m_Name: Spawner 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!4 &491568 20 | Transform: 21 | m_ObjectHideFlags: 1 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | m_GameObject: {fileID: 105404} 25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 26 | m_LocalPosition: {x: 0, y: 0, z: 0} 27 | m_LocalScale: {x: 1, y: 1, z: 1} 28 | m_Children: [] 29 | m_Father: {fileID: 0} 30 | m_RootOrder: 0 31 | --- !u!114 &11493774 32 | MonoBehaviour: 33 | m_ObjectHideFlags: 1 34 | m_PrefabParentObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 105404} 37 | m_Enabled: 1 38 | m_EditorHideFlags: 0 39 | m_Script: {fileID: 11500000, guid: b337c53d2671c0a42aea40f4e5df0ae2, type: 3} 40 | m_Name: 41 | m_EditorClassIdentifier: 42 | obj: {fileID: 0} 43 | objectSizeRange: {x: 1, y: 1} 44 | numberOfObjects: 10 45 | boundaryPadding: 1 46 | spaceBetweenObjects: 1 47 | thingsToAvoid: [] 48 | --- !u!1001 &100100000 49 | Prefab: 50 | m_ObjectHideFlags: 1 51 | serializedVersion: 2 52 | m_Modification: 53 | m_TransformParent: {fileID: 0} 54 | m_Modifications: 55 | - target: {fileID: 0} 56 | propertyPath: objectSizeRange.y 57 | value: 1 58 | objectReference: {fileID: 0} 59 | m_RemovedComponents: [] 60 | m_ParentPrefab: {fileID: 0} 61 | m_RootGameObject: {fileID: 105404} 62 | m_IsPrefabParent: 1 63 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Spawner.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c40413500bcaa84f884e9834bc27ec9 3 | timeCreated: 1445264925 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/WallAvoidanceUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3356bb3bf08034540bdb1c85eba417e0 3 | timeCreated: 1445034535 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Wander1Unit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &101970 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 499076} 11 | - 33: {fileID: 3360636} 12 | - 23: {fileID: 2303730} 13 | - 54: {fileID: 5405632} 14 | - 135: {fileID: 13565118} 15 | - 114: {fileID: 11477000} 16 | - 114: {fileID: 11439074} 17 | - 114: {fileID: 11467628} 18 | m_Layer: 0 19 | m_Name: Wander1Unit 20 | m_TagString: Untagged 21 | m_Icon: {fileID: 0} 22 | m_NavMeshLayer: 0 23 | m_StaticEditorFlags: 0 24 | m_IsActive: 1 25 | --- !u!4 &499076 26 | Transform: 27 | m_ObjectHideFlags: 1 28 | m_PrefabParentObject: {fileID: 0} 29 | m_PrefabInternal: {fileID: 100100000} 30 | m_GameObject: {fileID: 101970} 31 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 32 | m_LocalPosition: {x: 0, y: 0, z: 0} 33 | m_LocalScale: {x: 1, y: 1, z: 1} 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_RootOrder: 0 37 | --- !u!23 &2303730 38 | MeshRenderer: 39 | m_ObjectHideFlags: 1 40 | m_PrefabParentObject: {fileID: 0} 41 | m_PrefabInternal: {fileID: 100100000} 42 | m_GameObject: {fileID: 101970} 43 | m_Enabled: 1 44 | m_CastShadows: 1 45 | m_ReceiveShadows: 1 46 | m_Materials: 47 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 48 | m_SubsetIndices: 49 | m_StaticBatchRoot: {fileID: 0} 50 | m_UseLightProbes: 1 51 | m_ReflectionProbeUsage: 1 52 | m_ProbeAnchor: {fileID: 0} 53 | m_ScaleInLightmap: 1 54 | m_PreserveUVs: 0 55 | m_ImportantGI: 0 56 | m_AutoUVMaxDistance: .5 57 | m_AutoUVMaxAngle: 89 58 | m_LightmapParameters: {fileID: 0} 59 | m_SortingLayerID: 0 60 | m_SortingOrder: 0 61 | --- !u!33 &3360636 62 | MeshFilter: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 101970} 67 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 68 | --- !u!54 &5405632 69 | Rigidbody: 70 | m_ObjectHideFlags: 1 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | m_GameObject: {fileID: 101970} 74 | serializedVersion: 2 75 | m_Mass: 1 76 | m_Drag: 0 77 | m_AngularDrag: .0500000007 78 | m_UseGravity: 0 79 | m_IsKinematic: 0 80 | m_Interpolate: 0 81 | m_Constraints: 120 82 | m_CollisionDetection: 0 83 | --- !u!114 &11439074 84 | MonoBehaviour: 85 | m_ObjectHideFlags: 1 86 | m_PrefabParentObject: {fileID: 0} 87 | m_PrefabInternal: {fileID: 100100000} 88 | m_GameObject: {fileID: 101970} 89 | m_Enabled: 1 90 | m_EditorHideFlags: 0 91 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 92 | m_Name: 93 | m_EditorClassIdentifier: 94 | maxVelocity: 3.5 95 | maxAcceleration: 6.66599989 96 | targetRadius: .00499999989 97 | slowRadius: 1 98 | timeToTarget: .100000001 99 | turnSpeed: 20 100 | smoothing: 1 101 | numSamplesForSmoothing: 5 102 | sepMaxAcceleration: 10 103 | sepThreshold: 1.66659999 104 | collAvoidRadius: .5 105 | --- !u!114 &11467628 106 | MonoBehaviour: 107 | m_ObjectHideFlags: 1 108 | m_PrefabParentObject: {fileID: 0} 109 | m_PrefabInternal: {fileID: 100100000} 110 | m_GameObject: {fileID: 101970} 111 | m_Enabled: 1 112 | m_EditorHideFlags: 0 113 | m_Script: {fileID: 11500000, guid: 22a41feec586bae4ba2177d8457b7fa2, type: 3} 114 | m_Name: 115 | m_EditorClassIdentifier: 116 | wanderOffset: 1.5 117 | wanderRadius: 2 118 | wanderRate: .400000006 119 | --- !u!114 &11477000 120 | MonoBehaviour: 121 | m_ObjectHideFlags: 1 122 | m_PrefabParentObject: {fileID: 0} 123 | m_PrefabInternal: {fileID: 100100000} 124 | m_GameObject: {fileID: 101970} 125 | m_Enabled: 1 126 | m_EditorHideFlags: 0 127 | m_Script: {fileID: 11500000, guid: 9101efdc6414c2c48b7e2db10478de53, type: 3} 128 | m_Name: 129 | m_EditorClassIdentifier: 130 | --- !u!135 &13565118 131 | SphereCollider: 132 | m_ObjectHideFlags: 1 133 | m_PrefabParentObject: {fileID: 0} 134 | m_PrefabInternal: {fileID: 100100000} 135 | m_GameObject: {fileID: 101970} 136 | m_Material: {fileID: 0} 137 | m_IsTrigger: 0 138 | m_Enabled: 1 139 | serializedVersion: 2 140 | m_Radius: .300000012 141 | m_Center: {x: 0, y: 0, z: -.300000012} 142 | --- !u!1001 &100100000 143 | Prefab: 144 | m_ObjectHideFlags: 1 145 | serializedVersion: 2 146 | m_Modification: 147 | m_TransformParent: {fileID: 0} 148 | m_Modifications: 149 | - target: {fileID: 0} 150 | propertyPath: m_Constraints 151 | value: 120 152 | objectReference: {fileID: 0} 153 | m_RemovedComponents: [] 154 | m_ParentPrefab: {fileID: 0} 155 | m_RootGameObject: {fileID: 101970} 156 | m_IsPrefabParent: 1 157 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Wander1Unit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 646771f426c6db7489d21b5d19614acd 3 | timeCreated: 1444858143 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Wander2Unit.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &163698 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 486792} 11 | - 33: {fileID: 3359818} 12 | - 23: {fileID: 2332060} 13 | - 54: {fileID: 5424576} 14 | - 135: {fileID: 13510442} 15 | - 114: {fileID: 11481402} 16 | - 114: {fileID: 11457380} 17 | - 114: {fileID: 11474718} 18 | m_Layer: 0 19 | m_Name: Wander2Unit 20 | m_TagString: Untagged 21 | m_Icon: {fileID: 0} 22 | m_NavMeshLayer: 0 23 | m_StaticEditorFlags: 0 24 | m_IsActive: 1 25 | --- !u!4 &486792 26 | Transform: 27 | m_ObjectHideFlags: 1 28 | m_PrefabParentObject: {fileID: 0} 29 | m_PrefabInternal: {fileID: 100100000} 30 | m_GameObject: {fileID: 163698} 31 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 32 | m_LocalPosition: {x: 0, y: 0, z: 0} 33 | m_LocalScale: {x: 1, y: 1, z: 1} 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_RootOrder: 0 37 | --- !u!23 &2332060 38 | MeshRenderer: 39 | m_ObjectHideFlags: 1 40 | m_PrefabParentObject: {fileID: 0} 41 | m_PrefabInternal: {fileID: 100100000} 42 | m_GameObject: {fileID: 163698} 43 | m_Enabled: 1 44 | m_CastShadows: 1 45 | m_ReceiveShadows: 1 46 | m_Materials: 47 | - {fileID: 2100000, guid: 91a6a98d47f55e347a20c2dadf7a8b73, type: 2} 48 | m_SubsetIndices: 49 | m_StaticBatchRoot: {fileID: 0} 50 | m_UseLightProbes: 1 51 | m_ReflectionProbeUsage: 1 52 | m_ProbeAnchor: {fileID: 0} 53 | m_ScaleInLightmap: 1 54 | m_PreserveUVs: 0 55 | m_ImportantGI: 0 56 | m_AutoUVMaxDistance: .5 57 | m_AutoUVMaxAngle: 89 58 | m_LightmapParameters: {fileID: 0} 59 | m_SortingLayerID: 0 60 | m_SortingOrder: 0 61 | --- !u!33 &3359818 62 | MeshFilter: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 163698} 67 | m_Mesh: {fileID: 4300000, guid: fb79ccf0fd6eb084587be081e0c6ddac, type: 3} 68 | --- !u!54 &5424576 69 | Rigidbody: 70 | m_ObjectHideFlags: 1 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | m_GameObject: {fileID: 163698} 74 | serializedVersion: 2 75 | m_Mass: 1 76 | m_Drag: 0 77 | m_AngularDrag: .0500000007 78 | m_UseGravity: 0 79 | m_IsKinematic: 0 80 | m_Interpolate: 0 81 | m_Constraints: 120 82 | m_CollisionDetection: 0 83 | --- !u!114 &11457380 84 | MonoBehaviour: 85 | m_ObjectHideFlags: 1 86 | m_PrefabParentObject: {fileID: 0} 87 | m_PrefabInternal: {fileID: 100100000} 88 | m_GameObject: {fileID: 163698} 89 | m_Enabled: 1 90 | m_EditorHideFlags: 0 91 | m_Script: {fileID: 11500000, guid: a6f58141e9f357e448fd2fa6f1afc1f7, type: 3} 92 | m_Name: 93 | m_EditorClassIdentifier: 94 | maxVelocity: 3.5 95 | maxAcceleration: 6.66599989 96 | targetRadius: .00499999989 97 | slowRadius: 1 98 | timeToTarget: .100000001 99 | turnSpeed: 20 100 | smoothing: 1 101 | numSamplesForSmoothing: 5 102 | sepMaxAcceleration: 10 103 | sepThreshold: 1.66659999 104 | collAvoidRadius: .5 105 | --- !u!114 &11474718 106 | MonoBehaviour: 107 | m_ObjectHideFlags: 1 108 | m_PrefabParentObject: {fileID: 0} 109 | m_PrefabInternal: {fileID: 100100000} 110 | m_GameObject: {fileID: 163698} 111 | m_Enabled: 1 112 | m_EditorHideFlags: 0 113 | m_Script: {fileID: 11500000, guid: b5943b3ef333d3b45b456e9a8ce26d40, type: 3} 114 | m_Name: 115 | m_EditorClassIdentifier: 116 | wanderRadius: 1.20000005 117 | wanderDistance: 2 118 | wanderJitter: 40 119 | --- !u!114 &11481402 120 | MonoBehaviour: 121 | m_ObjectHideFlags: 1 122 | m_PrefabParentObject: {fileID: 0} 123 | m_PrefabInternal: {fileID: 100100000} 124 | m_GameObject: {fileID: 163698} 125 | m_Enabled: 1 126 | m_EditorHideFlags: 0 127 | m_Script: {fileID: 11500000, guid: ecb0c8fe6f551294bbba53fde5ed4b5d, type: 3} 128 | m_Name: 129 | m_EditorClassIdentifier: 130 | --- !u!135 &13510442 131 | SphereCollider: 132 | m_ObjectHideFlags: 1 133 | m_PrefabParentObject: {fileID: 0} 134 | m_PrefabInternal: {fileID: 100100000} 135 | m_GameObject: {fileID: 163698} 136 | m_Material: {fileID: 0} 137 | m_IsTrigger: 0 138 | m_Enabled: 1 139 | serializedVersion: 2 140 | m_Radius: .300000012 141 | m_Center: {x: 0, y: 0, z: -.300000012} 142 | --- !u!1001 &100100000 143 | Prefab: 144 | m_ObjectHideFlags: 1 145 | serializedVersion: 2 146 | m_Modification: 147 | m_TransformParent: {fileID: 0} 148 | m_Modifications: 149 | - target: {fileID: 0} 150 | propertyPath: m_Constraints 151 | value: 120 152 | objectReference: {fileID: 0} 153 | m_RemovedComponents: [] 154 | m_ParentPrefab: {fileID: 0} 155 | m_RootGameObject: {fileID: 163698} 156 | m_IsPrefabParent: 1 157 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/Wander2Unit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11eae3e40166fd0429da122769705e13 3 | timeCreated: 1444858392 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Prefabs/WanderAvoidUnit.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd1d62c70d726f34eb654e97eb3686cd 3 | timeCreated: 1445290612 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 697f66ace6f88074695e73d7159f4f19 3 | folderAsset: yes 4 | timeCreated: 1444774494 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/ArriveUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class ArriveUnit : MonoBehaviour { 5 | 6 | public Vector3 targetPosition; 7 | 8 | private SteeringBasics steeringBasics; 9 | 10 | // Use this for initialization 11 | void Start() 12 | { 13 | steeringBasics = GetComponent(); 14 | } 15 | 16 | // Update is called once per frame 17 | void Update() 18 | { 19 | Vector3 accel = steeringBasics.Arrive(targetPosition); 20 | 21 | steeringBasics.Steer(accel); 22 | steeringBasics.LookWhereYoureGoing(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/ArriveUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecfcf724a92030e4eb05c1a23e70116f 3 | timeCreated: 1445137354 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Camera.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0faec369b0e19734fa127edb321ad3f3 3 | folderAsset: yes 4 | timeCreated: 1445458543 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Camera/CameraMovement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class CameraMovement : MonoBehaviour { 5 | 6 | public Transform target; 7 | 8 | private Vector3 displacement; 9 | // Use this for initialization 10 | void Start () { 11 | //target = GameObject.Find ("Player").transform; 12 | 13 | displacement = transform.position - target.position; 14 | } 15 | 16 | // LateUpdate is called once per frame after the other normal Update functions have already run 17 | void LateUpdate () { 18 | //Debug.Log (Vector2.Distance (transform.position, target.position)); 19 | if(target != null) { 20 | transform.position = target.position + displacement; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Camera/CameraMovement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49346cc1dafa05c429a4659d89e3a1f6 3 | timeCreated: 1445450394 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Camera/InfiniteGrid.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | /** 6 | * 这个类将在x / y方向上为相机创建一个无限的网格。把这个脚本放在你的相机上。 7 | */ 8 | public class InfiniteGrid : MonoBehaviour { 9 | 10 | public bool show = true; 11 | 12 | public float cellSize = 1; 13 | 14 | public float zPosition = 0; 15 | 16 | private float[] GetGridBounds() { 17 | float distToGrid = zPosition - transform.position.z; 18 | 19 | float angle = (GetComponent().fieldOfView / 2) * Mathf.Deg2Rad; 20 | 21 | float halfHeight = Mathf.Tan (angle) * distToGrid; 22 | float halfWidth = GetComponent().aspect * halfHeight; 23 | 24 | float[] bounds = new float[4]; 25 | 26 | // Get the camera bounds 27 | bounds [0] = transform.position.x - halfWidth; 28 | bounds [1] = transform.position.y - halfHeight; 29 | bounds [2] = transform.position.x + halfWidth; 30 | bounds [3] = transform.position.y + halfHeight; 31 | 32 | // Convert the camera bounds to the grid bounds 33 | bounds [0] = Mathf.Floor(bounds [0] / cellSize) * cellSize; 34 | bounds [1] = Mathf.Floor(bounds [1] / cellSize) * cellSize; 35 | bounds [2] = Mathf.Ceil(bounds [2] / cellSize) * cellSize; 36 | bounds [3] = Mathf.Ceil(bounds [3] / cellSize) * cellSize; 37 | 38 | return bounds; 39 | } 40 | 41 | public Material lineMat; 42 | // GL 是Unity提供很底层的API, 可以画一些图形 43 | void OnPostRender() 44 | { 45 | GL.Begin( GL.LINES ); 46 | 47 | if(show) 48 | { 49 | Material lineMaterial = lineMat; 50 | lineMaterial.SetPass( 0 ); 51 | 52 | float[] bounds = GetGridBounds (); 53 | 54 | //X axis lines 55 | for(float j = 0; bounds[1] + j <= bounds[3]; j += cellSize) 56 | { 57 | GL.Vertex3( bounds[0], bounds[1] + j, zPosition); 58 | GL.Vertex3( bounds[2], bounds[1] + j, zPosition); 59 | } 60 | 61 | //Y axis lines 62 | for(float k = 0; bounds[0] + k <= bounds[2]; k += cellSize) 63 | { 64 | GL.Vertex3( bounds[0] + k, bounds[1], zPosition); 65 | GL.Vertex3( bounds[0] + k, bounds[3], zPosition); 66 | } 67 | } 68 | 69 | GL.End(); 70 | } 71 | } -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Camera/InfiniteGrid.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 770499eb59bf16e40babd2e41f691bda 3 | timeCreated: 1445450857 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/ColAvoidUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class ColAvoidUnit : MonoBehaviour { 5 | // 编辑器设置 6 | public LinePath path; 7 | 8 | // 组件 9 | private SteeringBasics steeringBasics; 10 | private FollowPath followPath; 11 | private CollisionAvoidance colAvoid; 12 | 13 | private NearSensor colAvoidSensor; 14 | 15 | void Start() 16 | { 17 | path.calcDistances(); 18 | 19 | steeringBasics = GetComponent(); 20 | followPath = GetComponent(); 21 | colAvoid = GetComponent(); 22 | 23 | colAvoidSensor = transform.Find("ColAvoidSensor").GetComponent(); 24 | } 25 | 26 | void Update() 27 | { 28 | // 调试 29 | path.draw(); 30 | 31 | // 是否原路返回 32 | if (isAtEndOfPath()) 33 | { 34 | path.reversePath(); 35 | } 36 | 37 | // 躲避 加速度 38 | Vector3 accel = colAvoid.GetSteering(colAvoidSensor.targets); 39 | 40 | // 不需要躲避 就沿着路径走 41 | if (accel.magnitude < 0.005f) 42 | { 43 | accel = followPath.getSteering(path); 44 | } 45 | 46 | // 设置刚体速度 和 朝向 47 | steeringBasics.Steer(accel); 48 | steeringBasics.LookWhereYoureGoing(); 49 | } 50 | 51 | public bool isAtEndOfPath() 52 | { 53 | return Vector3.Distance(path.endNode, transform.position) < followPath.stopRadius; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/ColAvoidUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fa9bf6680359d048833285e2586e9be 3 | timeCreated: 1445041211 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/EvadeUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class EvadeUnit : MonoBehaviour 5 | { 6 | public Rigidbody target; 7 | 8 | private SteeringBasics steeringBasics; 9 | private Evade evade; 10 | 11 | // Use this for initialization 12 | void Start() 13 | { 14 | steeringBasics = GetComponent(); 15 | evade = GetComponent(); 16 | } 17 | 18 | void Update() 19 | { 20 | Vector3 accel = evade.GetSteering(target); 21 | 22 | steeringBasics.Steer(accel); 23 | steeringBasics.LookWhereYoureGoing(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/EvadeUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0a3e859ea8fe534488413270935c6c1 3 | timeCreated: 1445141347 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/FleeUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class FleeUnit : MonoBehaviour 5 | { 6 | 7 | public Transform target; 8 | 9 | private SteeringBasics steeringBasics; 10 | private Flee flee; 11 | 12 | // Use this for initialization 13 | void Start() 14 | { 15 | steeringBasics = GetComponent(); 16 | flee = GetComponent(); 17 | } 18 | 19 | void Update() 20 | { 21 | // 得到线性加速度 22 | Vector3 accel = flee.getSteering(target.position); 23 | // 设置刚体速度 24 | steeringBasics.Steer(accel); 25 | // 设置朝向 26 | steeringBasics.LookWhereYoureGoing(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/FleeUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55191c5ba3a442d4e8b1f817bdb15378 3 | timeCreated: 1445125027 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/FlockingUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class FlockingUnit : MonoBehaviour 5 | { 6 | // 参数 7 | public float cohesionWeight = 1.5f; 8 | public float separationWeight = 2f; 9 | public float velocityMatchWeight = 1f; 10 | 11 | // 速度 12 | private SteeringBasics steeringBasics; 13 | private Wander2 wander; 14 | private Cohesion cohesion; 15 | private Separation separation; 16 | private VelocityMatch velocityMatch; 17 | 18 | private NearSensor sensor; 19 | 20 | // Use this for initialization 21 | void Start() 22 | { 23 | steeringBasics = GetComponent(); 24 | wander = GetComponent(); 25 | cohesion = GetComponent(); 26 | separation = GetComponent(); 27 | velocityMatch = GetComponent(); 28 | 29 | sensor = transform.Find("Sensor").GetComponent(); 30 | } 31 | 32 | // Update is called once per frame 33 | void Update() 34 | { 35 | Vector3 accel = Vector3.zero; 36 | // 集群加速度 37 | accel += cohesion.GetSteering(sensor.targets) * cohesionWeight; 38 | // 分隔加速度 39 | accel += separation.GetSteering(sensor.targets) * separationWeight; 40 | // 速度匹配加速度 41 | accel += velocityMatch.GetSteering(sensor.targets) * velocityMatchWeight; 42 | 43 | // 如果没有那些 影响, 就漫游好了 44 | if (accel.magnitude < 0.005f) 45 | { 46 | accel = wander.GetSteering(); 47 | } 48 | 49 | // 设置刚体速度 和 朝向 50 | steeringBasics.Steer(accel); 51 | steeringBasics.LookWhereYoureGoing(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/FlockingUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b367b651c2e510041a2a4431b028bed2 3 | timeCreated: 1445651384 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/FollowPathUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class FollowPathUnit : MonoBehaviour { 5 | 6 | // 是否循环 7 | public bool pathLoop = false; 8 | // 原路返回 9 | public bool reversePath = false; 10 | // 编辑器设置路径的关键点 11 | public LinePath path; 12 | 13 | // 其他组件 14 | private SteeringBasics steeringBasics; 15 | private FollowPath followPath; 16 | 17 | 18 | void Start () { 19 | // 计算距离 20 | path.calcDistances(); 21 | 22 | steeringBasics = GetComponent(); 23 | followPath = GetComponent(); 24 | } 25 | 26 | 27 | void Update () { 28 | 29 | path.draw(); 30 | 31 | // 执行原路返回的逻辑 32 | if (reversePath && isAtEndOfPath()) 33 | { 34 | path.reversePath(); 35 | } 36 | 37 | // 计算线性加速度 38 | Vector3 accel = followPath.getSteering(path, pathLoop); 39 | 40 | // 设置刚体速度 41 | steeringBasics.Steer(accel); 42 | // 朝向 43 | steeringBasics.LookWhereYoureGoing(); 44 | } 45 | 46 | // 到达最后节点 47 | public bool isAtEndOfPath() 48 | { 49 | return Vector3.Distance(path.endNode, transform.position) < followPath.stopRadius; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/FollowPathUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d127f162cb2d3b34784df7d7696be4e0 3 | timeCreated: 1444774830 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/HideUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class HideUnit : MonoBehaviour { 5 | public Rigidbody target; 6 | 7 | private SteeringBasics steeringBasics; 8 | private Hide hide; 9 | private Spawner obstacleSpawner; 10 | 11 | private WallAvoidance wallAvoid; 12 | 13 | void Start() 14 | { 15 | steeringBasics = GetComponent(); 16 | hide = GetComponent(); 17 | obstacleSpawner = GameObject.Find("ObstacleSpawner").GetComponent(); 18 | 19 | wallAvoid = GetComponent(); 20 | } 21 | 22 | void Update() 23 | { 24 | // 得到加速度 躲在障碍物后面,同时不被目标看到 25 | Vector3 hidePosition; 26 | Vector3 hideAccel = hide.GetSteering(target, obstacleSpawner.objs, out hidePosition); 27 | 28 | // 如果撞墙要 解决 29 | Vector3 accel = wallAvoid.GetSteering(hidePosition - transform.position); 30 | 31 | // 没有撞墙 (说明如果撞墙先解决撞墙) 32 | if (accel.magnitude < 0.005f) 33 | { 34 | accel = hideAccel; 35 | } 36 | 37 | // 设置速度 和 朝向 38 | steeringBasics.Steer(accel); 39 | steeringBasics.LookWhereYoureGoing(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/HideUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8895fef33386c5d4eb6e38eb84205740 3 | timeCreated: 1445294691 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/InterposeUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class InterposeUnit : MonoBehaviour { 5 | 6 | public Rigidbody target1; 7 | public Rigidbody target2; 8 | 9 | private SteeringBasics steeringBasics; 10 | 11 | // Use this for initialization 12 | void Start() 13 | { 14 | steeringBasics = GetComponent(); 15 | } 16 | 17 | // Update is called once per frame 18 | void Update() 19 | { 20 | Vector3 accel = steeringBasics.interpose(target1, target2); 21 | 22 | steeringBasics.Steer(accel); 23 | steeringBasics.LookWhereYoureGoing(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/InterposeUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3536641d912cf8b4c9d3c259b62f5e24 3 | timeCreated: 1445204369 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3619010d62741404f97da7be43ca847b 3 | folderAsset: yes 4 | timeCreated: 1444774530 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Cohesion.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | [RequireComponent(typeof(SteeringBasics))] 6 | public class Cohesion : MonoBehaviour { 7 | // 我的前方视野 8 | public float facingCosine = 120f; 9 | 10 | private float facingCosineVal; 11 | 12 | private SteeringBasics steeringBasics; 13 | 14 | // Use this for initialization 15 | void Start () { 16 | facingCosineVal = Mathf.Cos(facingCosine * Mathf.Deg2Rad); 17 | steeringBasics = GetComponent(); 18 | } 19 | 20 | public Vector3 GetSteering(ICollection targets) 21 | { 22 | Vector3 centerOfMass = Vector3.zero; 23 | int count = 0; 24 | 25 | /* 得到我前方视野内所有角色的 中心 */ 26 | foreach (Rigidbody r in targets) 27 | { 28 | // 在视野内 (视野是 无限扇形) 29 | if (steeringBasics.isFacing(r.position, facingCosineVal)) 30 | { 31 | centerOfMass += r.position; 32 | count++; 33 | } 34 | } 35 | 36 | if (count == 0) // 我前面没有人。 漫游好了 37 | { 38 | return Vector3.zero; 39 | } 40 | else 41 | { 42 | // 目标目标位置 43 | centerOfMass = centerOfMass / count; 44 | 45 | return steeringBasics.Arrive(centerOfMass); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Cohesion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1dcff34f8b3e02b44a21610e0e8c523b 3 | timeCreated: 1445674703 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/CollisionAvoidance.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public class CollisionAvoidance : MonoBehaviour 6 | { 7 | public float maxAcceleration = 15f; 8 | // 角色半径 9 | private float characterRadius; 10 | 11 | private Rigidbody rb; 12 | 13 | 14 | void Start() 15 | { 16 | characterRadius = SteeringBasics.GetBoundingRadius(transform); 17 | 18 | rb = GetComponent(); 19 | } 20 | 21 | public Vector3 GetSteering(ICollection targets) 22 | { 23 | Vector3 acceleration = Vector3.zero; 24 | 25 | /* 1. 找出这个角色将会与之碰撞的第一个目标 */ 26 | 27 | /* 第一次碰撞时间 */ 28 | float shortestTime = float.PositiveInfinity; // 正无穷大 临时值 29 | 30 | /* The first target that will collide and other data that 31 | * we will need and can avoid recalculating */ 32 | 33 | // 重置数据 ,并且可以避免重新计算 34 | Rigidbody firstTarget = null; 35 | //float firstMinSeparation = 0, firstDistance = 0; 36 | float firstMinSeparation = 0, 37 | firstDistance = 0, 38 | firstRadius = 0; 39 | Vector3 firstRelativePos = Vector3.zero, 40 | firstRelativeVel = Vector3.zero; 41 | 42 | foreach (Rigidbody r in targets) 43 | { 44 | /* 计算碰撞时间 */ 45 | // 相差位置 46 | Vector3 relativePos = transform.position - r.position; 47 | // 相差速度 48 | Vector3 relativeVel = rb.velocity - r.velocity; 49 | // 标量 50 | float distance = relativePos.magnitude; 51 | float relativeSpeed = relativeVel.magnitude; 52 | 53 | // 说明朝着相反的方向运动 并且速度一样 54 | if (relativeSpeed == 0) 55 | { 56 | continue; 57 | } 58 | 59 | // 60 | float timeToCollision = -1 * Vector3.Dot(relativePos, relativeVel) / (relativeSpeed * relativeSpeed); 61 | 62 | /* 检查它们是否会碰撞 */ 63 | Vector3 separation = relativePos + relativeVel * timeToCollision; 64 | float minSeparation = separation.magnitude; 65 | 66 | float targetRadius = SteeringBasics.GetBoundingRadius(r.transform); 67 | 68 | // 两者分离了 69 | if (minSeparation > characterRadius + targetRadius) 70 | //if (minSeparation > 2 * agentRadius) 71 | { 72 | continue; 73 | } 74 | 75 | /* 检查它是否是最短, 是的话就纪录最短的 */ 76 | if (timeToCollision > 0 && timeToCollision < shortestTime) 77 | { 78 | shortestTime = timeToCollision; 79 | firstTarget = r; 80 | firstMinSeparation = minSeparation; 81 | firstDistance = distance; 82 | firstRelativePos = relativePos; 83 | firstRelativeVel = relativeVel; 84 | firstRadius = targetRadius; 85 | } 86 | } 87 | 88 | /* 2. 计算加速度 */ 89 | 90 | /* 如果没有目标,就退出 */ 91 | if (firstTarget == null) 92 | { 93 | return acceleration; 94 | } 95 | 96 | /* If we are going to collide with no separation or if we are already colliding then 97 | * Steer based on current position */ 98 | // 如果我们要在没有分离的情况下发生碰撞,或者如果我们已经碰撞了,然后根据当前位置进行碰撞 99 | if (firstMinSeparation <= 0 || firstDistance < characterRadius + firstRadius) 100 | //if (firstMinSeparation <= 0 || firstDistance < 2 * agentRadius) 101 | { 102 | acceleration = transform.position - firstTarget.position; 103 | } 104 | /* 计算未来的相对位置 */ 105 | else 106 | { 107 | acceleration = firstRelativePos + firstRelativeVel * shortestTime; 108 | } 109 | 110 | /* 远离目标 */ 111 | acceleration.Normalize(); 112 | acceleration *= maxAcceleration; 113 | 114 | return acceleration; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/CollisionAvoidance.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d0fb7ad878c96643a9ef33951d933ba 3 | timeCreated: 1445040328 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Evade.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(Flee))] 5 | public class Evade : MonoBehaviour 6 | { 7 | /* // 未来预测的最大预测时间 */ 8 | public float maxPrediction = 1f; 9 | 10 | private Flee flee; 11 | 12 | // Use this for initialization 13 | void Start() 14 | { 15 | flee = GetComponent(); 16 | } 17 | 18 | public Vector3 GetSteering(Rigidbody target) 19 | { 20 | /* 计算到目标的距离 */ 21 | Vector3 displacement = target.position - transform.position; 22 | float distance = displacement.magnitude; 23 | 24 | /* 获得目标现在的速度 */ 25 | float speed = target.velocity.magnitude; 26 | 27 | // 计算预测时间 (不能让预测时间能跑的距离 超过当前的距离) 28 | float prediction; 29 | if (speed <= distance / maxPrediction) 30 | { 31 | prediction = maxPrediction; 32 | } 33 | else 34 | { 35 | prediction = distance / speed; 36 | // 目标到达角色前,将预测位置在往前一点 37 | prediction *= 0.9f; 38 | } 39 | 40 | // 目标 : 在目标位置基础上添加预测的部分 41 | Vector3 explicitTarget = target.position + target.velocity * prediction; 42 | 43 | // 使用之前的逃离功能 44 | return flee.getSteering(explicitTarget); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Evade.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52e7f349139dea54da032182166c26d8 3 | timeCreated: 1445141371 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Flee.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(Rigidbody))] 5 | public class Flee : MonoBehaviour { 6 | // 跟目标保持的距离 7 | public float panicDist = 3.5f; 8 | 9 | // 是否开启快到目标时减速 10 | public bool decelerateOnStop = true; 11 | 12 | public float maxAcceleration = 10f; 13 | 14 | // 跟 SteeringBasics2中的意思类似, 15 | public float timeToTarget = 0.1f; 16 | 17 | 18 | private Rigidbody rb; 19 | 20 | // Use this for initialization 21 | void Start () { 22 | rb = GetComponent(); 23 | } 24 | 25 | public Vector3 getSteering(Vector3 targetPosition) 26 | { 27 | // 得到方向 28 | Vector3 acceleration = transform.position - targetPosition; 29 | 30 | // 不需要逃离了 31 | if (acceleration.magnitude > panicDist) 32 | { 33 | // 如果我们要减速,就放慢速度 34 | if (decelerateOnStop && rb.velocity.magnitude > 0.001f) 35 | { 36 | 37 | if (acceleration.magnitude > maxAcceleration) 38 | { 39 | // 减速到0速 需要的时间 40 | acceleration = -rb.velocity / timeToTarget; 41 | 42 | } 43 | 44 | return acceleration; 45 | } 46 | else 47 | { 48 | rb.velocity = Vector2.zero; 49 | return Vector3.zero; 50 | } 51 | } 52 | 53 | // 以最大速度逃离 54 | return giveMaxAccel(acceleration); 55 | } 56 | 57 | // 最大加速度 58 | private Vector3 giveMaxAccel(Vector3 v) 59 | { 60 | // 移除z影响 61 | v.z = 0; 62 | 63 | v.Normalize(); 64 | 65 | v *= maxAcceleration; 66 | 67 | return v; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Flee.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cdf64bcab4d4d8468c92f1bc4b23f7c 3 | timeCreated: 1445140127 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/FollowPath.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent (typeof (SteeringBasics))] 5 | public class FollowPath : MonoBehaviour { 6 | // 用于结束的判断 7 | public float stopRadius = 0.005f; 8 | 9 | // 偏移量 10 | public float pathOffset = 0.71f; 11 | 12 | // 路径方向 13 | public float pathDirection = 1f; 14 | 15 | // 其他组件 16 | private SteeringBasics steeringBasics; 17 | private Rigidbody rb; 18 | 19 | void Start () { 20 | steeringBasics = GetComponent (); 21 | rb = GetComponent (); 22 | } 23 | 24 | // 得到线性加速度 25 | public Vector3 getSteering (LinePath path) { 26 | return getSteering (path, false); 27 | } 28 | 29 | 30 | public Vector3 getSteering (LinePath path, bool pathLoop) { 31 | Vector3 targetPosition; 32 | return getSteering(path, pathLoop, out targetPosition); 33 | } 34 | 35 | public Vector3 getSteering (LinePath path, bool pathLoop, out Vector3 targetPosition) { 36 | 37 | // 如果路径只有一个节点, 那么只需转到该位置 38 | if (path.Length == 1) { 39 | targetPosition = path[0]; 40 | } 41 | //否则, 在该路径上找到最接近的点, 然后转到该位置。 42 | else 43 | { 44 | if (!pathLoop) 45 | { 46 | /* 查找此路径上的 最终目标 */ 47 | Vector2 finalDestination = (pathDirection > 0) ? path[path.Length - 1] : path[0]; 48 | 49 | // 如果我们足够接近最终目的地, 就停止 50 | /* If we are close enough to the final destination then either stop moving or reverse if 51 | * the character is set to loop on paths */ 52 | if (Vector2.Distance(transform.position, finalDestination) < stopRadius) 53 | { 54 | targetPosition = finalDestination; 55 | 56 | rb.velocity = Vector2.zero; 57 | return Vector2.zero; 58 | } 59 | } 60 | 61 | /* 在给定路径上,得到最接近的位置点的参数*/ 62 | float param = path.getParam(transform.position); 63 | 64 | /* 向下移动的路径 */ 65 | param += pathDirection * pathOffset; 66 | 67 | /* 得到目标位置 */ 68 | targetPosition = path.getPosition(param, pathLoop); 69 | } 70 | 71 | return steeringBasics.Arrive(targetPosition); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/FollowPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 049423ef460e2524186c56ba0e274368 3 | timeCreated: 1440216999 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Hide.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | [RequireComponent(typeof(SteeringBasics))] 6 | [RequireComponent(typeof(Evade))] 7 | public class Hide : MonoBehaviour { 8 | // 边界距离 (距离障碍物 边的距离) 9 | public float distanceFromBoundary = 0.6f; 10 | 11 | // 组件 12 | private SteeringBasics steeringBasics; 13 | private Evade evade; 14 | 15 | // Use this for initialization 16 | void Start () { 17 | steeringBasics = GetComponent(); 18 | evade = GetComponent(); 19 | } 20 | 21 | public Vector3 GetSteering(Rigidbody target, ICollection obstacles, out Vector3 bestHidingSpot) 22 | { 23 | // 临时值 24 | float distToClostest = Mathf.Infinity; 25 | bestHidingSpot = Vector3.zero; 26 | 27 | // 找到最近的隐藏点 , 遍历所有障碍 28 | foreach(Rigidbody r in obstacles) 29 | { 30 | // 这个障碍 可以作为隐蔽的位置 31 | Vector3 hidingSpot = GetHidingPosition(r, target); 32 | 33 | // 离我多远 34 | float dist = Vector3.Distance(hidingSpot, transform.position); 35 | 36 | // 最近就保存 37 | if(dist < distToClostest) 38 | { 39 | distToClostest = dist; 40 | bestHidingSpot = hidingSpot; 41 | } 42 | } 43 | 44 | //如果没有发现隐藏点,就只躲避敌人 (比如我和敌人都处于所有障碍的一侧) 45 | if (distToClostest == Mathf.Infinity) 46 | { 47 | return evade.GetSteering(target); 48 | } 49 | 50 | Debug.DrawLine(transform.position, bestHidingSpot); 51 | 52 | // 返回加速度 53 | return steeringBasics.Arrive(bestHidingSpot); 54 | } 55 | 56 | // 获取隐藏位置 57 | private Vector3 GetHidingPosition(Rigidbody obstacle, Rigidbody target) 58 | { 59 | // 这个障碍物 附近 60 | float distAway = SteeringBasics.GetBoundingRadius(obstacle.transform) + distanceFromBoundary; 61 | // 目标看障碍物的方向(就要躲在这个方向上) 62 | Vector3 dir = obstacle.position - target.position; 63 | dir.Normalize(); 64 | 65 | // 最终隐藏位置 66 | return obstacle.position + dir * distAway; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Hide.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8303b41d5b5e59846808128b46019c95 3 | timeCreated: 1445294684 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/LinePath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 973b14114335987478bf67e5fd96e242 3 | timeCreated: 1444774557 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/NearSensor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | /// 6 | /// 接近传感器, 保存正在和我接触的,就是发生碰撞的 7 | /// 8 | public class NearSensor : MonoBehaviour { 9 | 10 | public HashSet targets = new HashSet(); 11 | 12 | void OnTriggerEnter(Collider other) { 13 | targets.Add (other.GetComponent()); 14 | } 15 | 16 | void OnTriggerExit(Collider other) { 17 | targets.Remove (other.GetComponent()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/NearSensor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cfdaa6b4aa86854cad04292e279f62e 3 | timeCreated: 1445040604 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/OffsetPursuit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(SteeringBasics))] 5 | public class OffsetPursuit : MonoBehaviour { 6 | /*未来预测的最大预测时间*/ 7 | public float maxPrediction = 1f; 8 | 9 | private Rigidbody rb; 10 | private SteeringBasics steeringBasics; 11 | 12 | // Use this for initialization 13 | void Start() 14 | { 15 | rb = GetComponent(); 16 | steeringBasics = GetComponent(); 17 | } 18 | 19 | public Vector3 getSteering(Rigidbody target, Vector3 offset) 20 | { 21 | Vector3 targetPos; 22 | return getSteering(target, offset, out targetPos); 23 | } 24 | 25 | public Vector3 getSteering(Rigidbody target, Vector3 offset, out Vector3 targetPos) 26 | { 27 | // 得到世界坐标的偏移位置 28 | Vector3 worldOffsetPos = target.position + target.transform.TransformDirection(offset); 29 | 30 | Debug.DrawLine(transform.position, worldOffsetPos); 31 | 32 | /* 计算距离到偏移点 */ 33 | Vector3 displacement = worldOffsetPos - transform.position; 34 | float distance = displacement.magnitude; 35 | 36 | 37 | float speed = rb.velocity.magnitude; 38 | 39 | /* 预测的距离不要超过当前距离 */ 40 | float prediction; 41 | if (speed <= distance / maxPrediction) 42 | { 43 | prediction = maxPrediction; 44 | } 45 | else 46 | { 47 | prediction = distance / speed; 48 | } 49 | 50 | /* 目标位置 */ 51 | targetPos = worldOffsetPos + target.velocity * prediction; 52 | 53 | return steeringBasics.Arrive(targetPos); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/OffsetPursuit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5663dbf892c30d74caacee862f4f7134 3 | timeCreated: 1445384830 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Pursue.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(SteeringBasics))] 5 | public class Pursue : MonoBehaviour 6 | { 7 | /*未来预测的最大预测时间*/ 8 | public float maxPrediction = 1f; 9 | 10 | // 组件引用 11 | private Rigidbody rb; 12 | private SteeringBasics steeringBasics; 13 | 14 | void Start () { 15 | rb = GetComponent(); 16 | steeringBasics = GetComponent(); 17 | } 18 | 19 | public Vector3 getSteering (Rigidbody target) { 20 | /* 计算到目标的距离 */ 21 | Vector3 displacement = target.position - transform.position; 22 | float distance = displacement.magnitude; 23 | 24 | /* 当前的速度 */ 25 | float speed = rb.velocity.magnitude; 26 | 27 | /* 计算预测时间 */ 28 | float prediction; 29 | if (speed <= distance / maxPrediction) // 加速 30 | { 31 | prediction = maxPrediction; 32 | } 33 | else 34 | { 35 | prediction = distance / speed; // 保持当前速度 36 | } 37 | 38 | /* 显式目标: 根据我们 thsink 的目标将目标放在一起*/ 39 | Vector3 explicitTarget = target.position + target.velocity*prediction; 40 | Debug.Log("target.position= " + target.position + " : prediction =" + target.velocity * prediction); 41 | 42 | return steeringBasics.seek(explicitTarget); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Pursue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2da78e0f74f9cf449361cf180272705 3 | timeCreated: 1445138555 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Separation.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public class Separation : MonoBehaviour { 6 | 7 | /* 分隔 加速度 */ 8 | public float sepMaxAcceleration = 25; 9 | 10 | /* 11 | 这应该是分离目标和自身之间可能的最大分离距离。 所以它应该是:分离传感器半径+最大目标半径(separation sensor radius + max target radius ) 12 | */ 13 | public float maxSepDist = 1f; 14 | 15 | private float boundingRadius; 16 | 17 | // Use this for initialization 18 | void Start() 19 | { 20 | boundingRadius = SteeringBasics.GetBoundingRadius(transform); 21 | } 22 | 23 | public Vector3 GetSteering(ICollection targets) 24 | { 25 | Vector3 acceleration = Vector3.zero; 26 | 27 | // 只要存在发生碰撞的就要想办法分离 28 | foreach (Rigidbody r in targets) 29 | { 30 | /* 远离的方向 */ 31 | Vector3 direction = transform.position - r.position; 32 | float dist = direction.magnitude; 33 | 34 | if (dist < maxSepDist) 35 | { 36 | float targetRadius = SteeringBasics.GetBoundingRadius(r.transform); 37 | 38 | /* 计算分离强度(可改为使用平方反比,而不是线性) */ 39 | var strength = sepMaxAcceleration * (maxSepDist - dist) / (maxSepDist - boundingRadius - targetRadius); 40 | 41 | /* 将分离加速度增加到现有的 Steer 上 (因为可能不是跟一个发生碰撞) */ 42 | direction.Normalize(); 43 | acceleration += direction * strength; 44 | } 45 | } 46 | 47 | return acceleration; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Separation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b54d0c5e57344f4994540c2b983849a 3 | timeCreated: 1445542880 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/SteeringBasics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6f58141e9f357e448fd2fa6f1afc1f7 3 | timeCreated: 1440217000 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/VelocityMatch.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | [RequireComponent(typeof(SteeringBasics))] 6 | public class VelocityMatch : MonoBehaviour 7 | { 8 | // 视野范围 9 | public float facingCosine = 90; 10 | 11 | public float timeToTarget = 0.1f; 12 | public float maxAcceleration = 4f; 13 | 14 | // 视野的余弦值 15 | private float facingCosineVal; 16 | 17 | 18 | private Rigidbody rb; 19 | private SteeringBasics steeringBasics; 20 | 21 | // Use this for initialization 22 | void Start() 23 | { 24 | facingCosineVal = Mathf.Cos(facingCosine * Mathf.Deg2Rad); 25 | 26 | rb = GetComponent(); 27 | steeringBasics = GetComponent(); 28 | } 29 | 30 | public Vector3 GetSteering(ICollection targets) 31 | { 32 | Vector3 accel = Vector3.zero; 33 | int count = 0; 34 | 35 | // 得到我视野内 所有人的 加速度平均值 36 | foreach (Rigidbody r in targets) 37 | { 38 | if (steeringBasics.isFacing(r.position, facingCosineVal)) 39 | { 40 | /* 计算我们想要匹配这个目标的加速度 */ 41 | Vector3 a = r.velocity - rb.velocity; 42 | /* 43 | Rather than accelerate the character to the correct speed in 1 second, 44 | accelerate so we reach the desired speed in timeToTarget seconds 45 | (if we were to actually accelerate for the full timeToTarget seconds). 46 | */ 47 | // 而不是在1秒内加速字符的正确速度,这样我们就能在目标秒内达到所期望的速度(如果我们要在目标秒内加速的话)。 48 | a = a / timeToTarget; 49 | 50 | accel += a; 51 | 52 | count++; 53 | } 54 | } 55 | 56 | if (count > 0) 57 | { 58 | accel = accel / count; 59 | 60 | /* 不要超值 */ 61 | if (accel.magnitude > maxAcceleration) 62 | { 63 | accel = accel.normalized * maxAcceleration; 64 | } 65 | } 66 | 67 | return accel; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/VelocityMatch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 712fa36ac13bbc043b7aabcad738e7dc 3 | timeCreated: 1445675196 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/WallAvoidance.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(SteeringBasics))] 5 | public class WallAvoidance : MonoBehaviour { 6 | 7 | /* 前方射线应该延伸多远 */ 8 | public float mainWhiskerLen = 1.25f; 9 | 10 | /* 跟墙保持的距离 */ 11 | public float wallAvoidDistance = 0.5f; 12 | 13 | // 两边射线应该延伸多远 14 | public float sideWhiskerLen = 0.701f; 15 | 16 | // 两边射线的角度 17 | public float sideWhiskerAngle = 45f; 18 | 19 | public float maxAcceleration = 40f; 20 | 21 | // 组件 22 | private Rigidbody rb; 23 | private SteeringBasics steeringBasics; 24 | 25 | // Use this for initialization 26 | void Start () { 27 | rb = GetComponent(); 28 | steeringBasics = GetComponent(); 29 | } 30 | 31 | public Vector3 GetSteering() 32 | { 33 | return GetSteering(rb.velocity); 34 | } 35 | 36 | public Vector3 GetSteering(Vector3 facingDir) 37 | { 38 | Vector3 acceleration = Vector3.zero; 39 | 40 | /* 创建射线方向向量 */ 41 | Vector3[] rayDirs = new Vector3[3]; 42 | // 自己前进的方向 43 | rayDirs[0] = facingDir.normalized; 44 | 45 | // 返回弧度, 对边y/临边x 46 | float orientation = Mathf.Atan2(rb.velocity.y, rb.velocity.x); 47 | 48 | // 两边的射线方向 49 | rayDirs[1] = orientationToVector(orientation + sideWhiskerAngle * Mathf.Deg2Rad); 50 | rayDirs[2] = orientationToVector(orientation - sideWhiskerAngle * Mathf.Deg2Rad); 51 | 52 | RaycastHit hit; 53 | 54 | /* 如果没有碰撞,什么也不做 */ 55 | if (!findObstacle(rayDirs, out hit)) 56 | { 57 | return acceleration; 58 | } 59 | 60 | /* 从墙上创建一个目标来 seek (这个方向和射线方向相反)*/ 61 | Vector3 targetPostition = hit.point + hit.normal * wallAvoidDistance; 62 | 63 | /* 如果速度和碰撞法线平行,则将目标向左或向右移动一点 (如果不矫正就会一直 垂直撞一个地方)*/ 64 | Vector3 cross = Vector3.Cross(rb.velocity, hit.normal); // 叉乘 判断两个向量是否平行 65 | // 点乘“·”计算得到的结果是一个标量; 平行向量 normalized的点乘 是 -1 或者 1, 垂直是0 66 | // 叉乘“×”得到的结果是一个垂直于原向量构成平面的向量。 平行向量的叉乘是零向量 67 | if (cross.magnitude < 0.005f) 68 | { 69 | targetPostition = targetPostition + new Vector3(-hit.normal.y, hit.normal.x, hit.normal.z); 70 | } 71 | 72 | // 返回最大加速度 73 | return steeringBasics.seek(targetPostition, maxAcceleration); 74 | } 75 | 76 | /* 将弧度 作为一个 单位向量返回 (极坐标公式)*/ 77 | private Vector3 orientationToVector(float orientation) 78 | { 79 | return new Vector3(Mathf.Cos(orientation), Mathf.Sin(orientation), 0); 80 | } 81 | 82 | /// 83 | /// 多个射线, 检测是否发生碰撞 84 | /// 85 | /// 86 | /// 87 | /// 88 | private bool findObstacle(Vector3[] rayDirs, out RaycastHit firstHit) 89 | { 90 | firstHit = new RaycastHit(); 91 | bool foundObs = false; 92 | 93 | for (int i = 0; i < rayDirs.Length; i++) 94 | { 95 | float rayDist = (i == 0) ? mainWhiskerLen : sideWhiskerLen; 96 | 97 | RaycastHit hit; 98 | 99 | if (Physics.Raycast(transform.position, rayDirs[i], out hit, rayDist)) 100 | { 101 | foundObs = true; 102 | firstHit = hit; 103 | break; 104 | } 105 | 106 | // 调试 107 | Debug.DrawLine(transform.position, transform.position + rayDirs[i] * rayDist); 108 | } 109 | 110 | return foundObs; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/WallAvoidance.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e008bb997f9e8cc42a7861ed1e5b45ea 3 | timeCreated: 1445034832 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Wander1.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(SteeringBasics))] 5 | public class Wander1 : MonoBehaviour { 6 | 7 | /* The forward of the wander square 偏移量 */ 8 | public float wanderOffset = 1.5f; 9 | 10 | /* The radius of the wander square 半径 */ 11 | public float wanderRadius = 4; 12 | 13 | /* The rate at which the wander orientation can change 比率 */ 14 | public float wanderRate = 0.4f; 15 | 16 | private float wanderOrientation = 0; 17 | 18 | private SteeringBasics steeringBasics; 19 | 20 | //private GameObject debugRing; 21 | 22 | void Start() { 23 | steeringBasics = GetComponent (); 24 | } 25 | 26 | public Vector3 getSteering() { 27 | // 当前角色的方向(弧度) 28 | float characterOrientation = transform.rotation.eulerAngles.z * Mathf.Deg2Rad; 29 | 30 | // 随机一个漫游方向(弧度) 31 | wanderOrientation += randomBinomial() * wanderRate; 32 | 33 | // 目标方向结合(弧度), 就是在角色方向上的一个偏移 34 | float targetOrientation = wanderOrientation + characterOrientation; 35 | 36 | // 角色的前方(偏移量) 37 | Vector3 targetPosition = transform.position + (orientationToVector (characterOrientation) * wanderOffset); 38 | 39 | // 得到目标位置 向量 c = a + b 就是对角线的方向 40 | targetPosition = targetPosition + (orientationToVector(targetOrientation) * wanderRadius); 41 | 42 | Debug.DrawLine (transform.position, targetPosition); 43 | 44 | // 得到 最大加速度 45 | return steeringBasics.seek (targetPosition); 46 | } 47 | 48 | /*返回一个随机数介于-1和1。 值为零的可能性更大。*/ 49 | float randomBinomial() { 50 | return Random.value - Random.value; 51 | } 52 | 53 | /* 返回方向的单位向量 */ 54 | Vector3 orientationToVector(float orientation) { 55 | // 位置 向量(极坐标 得到) // x = rcos(θ), y = rsin(θ), 56 | return new Vector3(Mathf.Cos(orientation), Mathf.Sin(orientation), 0); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Wander1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22a41feec586bae4ba2177d8457b7fa2 3 | timeCreated: 1444782458 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Wander2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Wander2 : MonoBehaviour { 5 | 6 | public float wanderRadius = 1.2f; 7 | 8 | public float wanderDistance = 2f; 9 | 10 | // 随机的最大位移(1秒) 11 | public float wanderJitter = 40f; 12 | 13 | private Vector3 wanderTarget; 14 | 15 | private SteeringBasics steeringBasics; 16 | 17 | void Start() 18 | { 19 | // 随机一个 弧度 (角度的取值范围 0~360, 弧度范围 0~2π) 20 | float theta = Random.value * 2 * Mathf.PI; 21 | 22 | // 位置 向量(极坐标 得到) // x = rcos(θ), y = rsin(θ), 23 | wanderTarget = new Vector3(wanderRadius * Mathf.Cos(theta), wanderRadius * Mathf.Sin(theta), 0f); 24 | 25 | steeringBasics = GetComponent(); 26 | } 27 | 28 | public Vector3 GetSteering() 29 | { 30 | // 得到一帧时间的 最大位移 31 | float jitter = wanderJitter * Time.deltaTime; 32 | 33 | // 向目标的位置添加一个小的随机向量(每一帧都调整新的) 34 | wanderTarget += new Vector3(Random.Range(-1f, 1f) * jitter, Random.Range(-1f, 1f) * jitter, 0f); 35 | 36 | // 得到新的漫游圈 37 | wanderTarget.Normalize(); 38 | wanderTarget *= wanderRadius; 39 | 40 | // 得到目标位置, 在角色的前方 right = ( 1, 0, 0 ) 41 | Vector3 targetPosition = transform.position + transform.right * wanderDistance + wanderTarget; 42 | 43 | // 为了调试用 44 | Debug.DrawLine(transform.position, targetPosition); 45 | 46 | return steeringBasics.seek(targetPosition); 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Movement/Wander2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5943b3ef333d3b45b456e9a8ce26d40 3 | timeCreated: 1444786057 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/OffsetPursuitUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class OffsetPursuitUnit : MonoBehaviour { 5 | 6 | public Rigidbody target; 7 | public Vector3 offset; 8 | public float groupLookDist = 1.5f; 9 | 10 | // 组件 11 | private SteeringBasics steeringBasics; 12 | private OffsetPursuit offsetPursuit; 13 | private Separation separation; 14 | 15 | private NearSensor sensor; 16 | 17 | void Start() 18 | { 19 | steeringBasics = GetComponent(); 20 | offsetPursuit = GetComponent(); 21 | separation = GetComponent(); 22 | 23 | sensor = transform.Find("SeparationSensor").GetComponent(); 24 | } 25 | 26 | void LateUpdate() 27 | { 28 | Vector3 targetPos; 29 | // 偏移追随加速度 和 分隔加速度 30 | Vector3 offsetAccel = offsetPursuit.getSteering(target, offset, out targetPos); 31 | Vector3 sepAccel = separation.GetSteering(sensor.targets); 32 | 33 | // 速度会 受到两个方面的影响 34 | steeringBasics.Steer(offsetAccel + sepAccel); 35 | 36 | /* 如果我们还在前往,那就要朝向我们要去的地方,其他的方向和我们的形成目标是一样的 */ 37 | if (Vector3.Distance(transform.position, targetPos) > groupLookDist) 38 | { 39 | steeringBasics.LookWhereYoureGoing(); 40 | } else 41 | { 42 | steeringBasics.lookAtDirection(target.rotation); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/OffsetPursuitUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06dca02ef11e90749b6ab44ba79f30da 3 | timeCreated: 1445384844 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/PursueUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class PursueUnit : MonoBehaviour { 5 | 6 | public Rigidbody target; 7 | 8 | private SteeringBasics steeringBasics; 9 | private Pursue pursue; 10 | 11 | // Use this for initialization 12 | void Start () { 13 | steeringBasics = GetComponent(); 14 | pursue = GetComponent(); 15 | } 16 | 17 | // Update is called once per frame 18 | void Update () { 19 | // 得到 线性加速度 20 | Vector3 accel = pursue.getSteering(target); 21 | 22 | // 设置刚体速度 23 | steeringBasics.Steer(accel); 24 | 25 | // 朝向 26 | steeringBasics.LookWhereYoureGoing(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/PursueUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28a5ea66325b4b34bb7fdd2c5706ca3e 3 | timeCreated: 1445138563 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/ScreenBoundary.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class ScreenBoundary : MonoBehaviour { 5 | 6 | private Vector3 bottomLeft; 7 | private Vector3 topRight; 8 | private Vector3 widthHeight; 9 | 10 | // Use this for initialization 11 | void Start () { 12 | float z = -1*Camera.main.transform.position.z; 13 | 14 | bottomLeft = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, z)); 15 | topRight = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, z)); 16 | widthHeight = topRight - bottomLeft; 17 | 18 | transform.localScale = new Vector3(widthHeight.x, widthHeight.y, transform.localScale.z); 19 | } 20 | 21 | void OnTriggerStay(Collider other) 22 | { 23 | Transform t = other.transform; 24 | 25 | if (t.position.x < bottomLeft.x) 26 | { 27 | t.position = new Vector3(t.position.x + widthHeight.x, t.position.y, t.position.z); 28 | } 29 | 30 | if (t.position.x > topRight.x) 31 | { 32 | t.position = new Vector3(t.position.x - widthHeight.x, t.position.y, t.position.z); 33 | } 34 | 35 | if (t.position.y < bottomLeft.y) 36 | { 37 | t.position = new Vector3(t.position.x, t.position.y + widthHeight.y, t.position.z); 38 | } 39 | 40 | if (t.position.y > topRight.y) 41 | { 42 | t.position = new Vector3(t.position.x, t.position.y - widthHeight.y, t.position.z); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/ScreenBoundary.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69e649a4f3e436244b1498ab2c59107d 3 | timeCreated: 1445036316 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/SeekUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class SeekUnit : MonoBehaviour { 5 | 6 | public Transform target; 7 | 8 | private SteeringBasics steeringBasics; 9 | 10 | // Use this for initialization 11 | void Start () { 12 | steeringBasics = GetComponent(); 13 | } 14 | 15 | // Update is called once per frame 16 | void Update () { 17 | Vector3 accel = steeringBasics.seek(target.position); 18 | 19 | steeringBasics.Steer(accel); 20 | steeringBasics.LookWhereYoureGoing(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/SeekUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ae73ab1d415c7c4a9ffbd954f482d15 3 | timeCreated: 1445123948 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Spawner.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public class Spawner : MonoBehaviour { 6 | // Prefab 7 | public Transform obj; 8 | // 用于随机的范围 9 | public Vector2 objectSizeRange = new Vector2(1, 2); 10 | // 一次性创建多少个 11 | public int numberOfObjects = 10; 12 | // 是否随机方向 13 | public bool randomizeOrientation = false; 14 | // 生成的内容要在 屏幕边界内 15 | public float boundaryPadding = 1f; 16 | // 生成的内容 距离现有的对象 要保持的最小距离 17 | public float spaceBetweenObjects = 1f; 18 | public Transform[] thingsToAvoid; 19 | 20 | private Vector3 bottomLeft; 21 | private Vector3 widthHeight; 22 | 23 | 24 | private float[] thingsToAvoidRadius; 25 | 26 | // 纪录现有生成的对象 27 | [System.NonSerialized] 28 | public List objs = new List(); 29 | 30 | void Start() 31 | { 32 | // 得到屏幕大小 33 | float z = -1 * Camera.main.transform.position.z; 34 | 35 | bottomLeft = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, z)); 36 | Vector3 topRight = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, z)); 37 | widthHeight = topRight - bottomLeft; 38 | 39 | // 如果需要的话 要避免和场景内其他对象重叠 纪录他们的数据 40 | thingsToAvoidRadius = new float[thingsToAvoid.Length]; 41 | 42 | for (int i = 0; i < thingsToAvoid.Length; i++) 43 | { 44 | thingsToAvoidRadius[i] = SteeringBasics.GetBoundingRadius(thingsToAvoid[i].transform); 45 | } 46 | 47 | // 创建就行了 48 | for (int i = 0; i < numberOfObjects; i++) 49 | { 50 | // 每次不一定创建成功,这里增加概率 51 | for(int j = 0; j < 10; j++) 52 | { 53 | if(TryToCreateObject()) 54 | { 55 | break; 56 | } 57 | } 58 | } 59 | } 60 | 61 | /// 62 | /// 尝试创建对象 63 | /// 64 | /// 65 | private bool TryToCreateObject() 66 | { 67 | // 随机位置 和 大小 68 | float size = Random.Range(objectSizeRange.x, objectSizeRange.y); 69 | float halfSize = size / 2f; 70 | 71 | Vector3 pos = new Vector3(); 72 | pos.x = bottomLeft.x + Random.Range(boundaryPadding + halfSize, widthHeight.x - boundaryPadding - halfSize); 73 | pos.y = bottomLeft.y + Random.Range(boundaryPadding + halfSize, widthHeight.y - boundaryPadding - halfSize); 74 | 75 | // 这个位置可以方式那就实例化 76 | if(CanPlaceObject(halfSize, pos)) 77 | { 78 | Transform t = Instantiate(obj, pos, Quaternion.identity) as Transform; 79 | t.localScale = new Vector3(size, size, obj.localScale.z); 80 | 81 | if(randomizeOrientation) 82 | { 83 | Vector3 euler = transform.eulerAngles; 84 | euler.z = Random.Range(0f, 360f); 85 | transform.eulerAngles = euler; 86 | } 87 | 88 | objs.Add(t.GetComponent()); 89 | 90 | return true; 91 | } 92 | 93 | return false; 94 | } 95 | 96 | /// 97 | /// 判断是否可以放置, 主要判断是否重叠 98 | /// 99 | /// 100 | /// 101 | /// 102 | private bool CanPlaceObject(float halfSize, Vector3 pos) 103 | { 104 | // 确保它不会与任何东西重叠 105 | for (int i = 0; i < thingsToAvoid.Length; i++) 106 | { 107 | float dist = Vector3.Distance(thingsToAvoid[i].position, pos); 108 | 109 | if(dist < halfSize + thingsToAvoidRadius[i]) 110 | { 111 | return false; 112 | } 113 | } 114 | 115 | //确保它不会与任何现有对象重叠 116 | foreach (Rigidbody o in objs) 117 | { 118 | float dist = Vector3.Distance(o.position, pos); 119 | 120 | float oRadius = SteeringBasics.GetBoundingRadius(o.transform); 121 | 122 | if (dist < oRadius + spaceBetweenObjects + halfSize) 123 | { 124 | return false; 125 | } 126 | } 127 | 128 | return true; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Spawner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b337c53d2671c0a42aea40f4e5df0ae2 3 | timeCreated: 1445210872 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/WallAvoidanceUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class WallAvoidanceUnit: MonoBehaviour 5 | { 6 | // 编辑器编辑 路径 7 | public LinePath path; 8 | 9 | // 组件 10 | private SteeringBasics steeringBasics; 11 | private WallAvoidance wallAvoidance; 12 | private FollowPath followPath; 13 | 14 | 15 | void Start() 16 | { 17 | path.calcDistances(); 18 | 19 | steeringBasics = GetComponent(); 20 | wallAvoidance = GetComponent(); 21 | followPath = GetComponent(); 22 | } 23 | 24 | // Update is called once per frame 25 | void Update() 26 | { 27 | // 到达终点了, 原路返回 28 | if (isAtEndOfPath()) 29 | { 30 | path.reversePath(); 31 | } 32 | 33 | // 得到加速度 (要躲避墙) 34 | Vector3 accel = wallAvoidance.GetSteering(); 35 | 36 | // 沿着路径走了 (约定没有碰撞时 加速度为0了) 37 | if (accel.magnitude < 0.005f) 38 | { 39 | accel = followPath.getSteering(path); 40 | } 41 | 42 | // 设置刚体 和 朝向 43 | steeringBasics.Steer(accel); 44 | steeringBasics.LookWhereYoureGoing(); 45 | 46 | // 调试 47 | path.draw(); 48 | } 49 | 50 | public bool isAtEndOfPath() 51 | { 52 | return Vector3.Distance(path.endNode, transform.position) < followPath.stopRadius; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/WallAvoidanceUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e09b033aa7b983469142324db471025 3 | timeCreated: 1444865876 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Wander1Unit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Wander1Unit : MonoBehaviour { 5 | 6 | private SteeringBasics steeringBasics; 7 | private Wander1 wander; 8 | 9 | // Use this for initialization 10 | void Start () { 11 | steeringBasics = GetComponent(); 12 | wander = GetComponent(); 13 | } 14 | 15 | // Update is called once per frame 16 | void Update () { 17 | Vector3 accel = wander.getSteering(); 18 | 19 | steeringBasics.Steer(accel); 20 | steeringBasics.LookWhereYoureGoing(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Wander1Unit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9101efdc6414c2c48b7e2db10478de53 3 | timeCreated: 1444784704 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Wander2Unit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Wander2Unit : MonoBehaviour 5 | { 6 | 7 | private SteeringBasics steeringBasics; 8 | private Wander2 wander; 9 | 10 | // Use this for initialization 11 | void Start() 12 | { 13 | steeringBasics = GetComponent(); 14 | wander = GetComponent(); 15 | } 16 | 17 | // Update is called once per frame 18 | void Update() 19 | { 20 | Vector3 accel = wander.GetSteering(); 21 | 22 | steeringBasics.Steer(accel); 23 | steeringBasics.LookWhereYoureGoing(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/Wander2Unit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecb0c8fe6f551294bbba53fde5ed4b5d 3 | timeCreated: 1444858155 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/WanderAvoidUnit.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class WanderAvoidUnit : MonoBehaviour { 5 | 6 | private SteeringBasics steeringBasics; 7 | private Wander2 wander; 8 | private CollisionAvoidance colAvoid; 9 | 10 | // 用于纪录当前都有谁与我发生碰撞 11 | private NearSensor colAvoidSensor; 12 | 13 | void Start() 14 | { 15 | steeringBasics = GetComponent(); 16 | wander = GetComponent(); 17 | colAvoid = GetComponent(); 18 | 19 | colAvoidSensor = transform.Find("ColAvoidSensor").GetComponent(); 20 | } 21 | 22 | // Update is called once per frame 23 | void Update() 24 | { 25 | // 加速度(有碰撞 就避免碰撞) 26 | Vector3 accel = colAvoid.GetSteering(colAvoidSensor.targets); 27 | 28 | // 没有任何碰撞的时候就 漫游 29 | if (accel.magnitude < 0.005f) 30 | { 31 | accel = wander.GetSteering(); 32 | } 33 | 34 | // 速度 35 | steeringBasics.Steer(accel); 36 | // 朝向 37 | steeringBasics.LookWhereYoureGoing(); 38 | } 39 | } -------------------------------------------------------------------------------- /Assets/unity-movement-ai/Scripts/WanderAvoidUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfc8bb85285d9974684a932daef751b2 3 | timeCreated: 1445210468 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Anton Pantev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PreviewImages/arrive.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/arrive.gif -------------------------------------------------------------------------------- /PreviewImages/colAvoid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/colAvoid.gif -------------------------------------------------------------------------------- /PreviewImages/evade.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/evade.gif -------------------------------------------------------------------------------- /PreviewImages/flocking.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/flocking.gif -------------------------------------------------------------------------------- /PreviewImages/followPath.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/followPath.gif -------------------------------------------------------------------------------- /PreviewImages/hide.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/hide.gif -------------------------------------------------------------------------------- /PreviewImages/interpose.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/interpose.gif -------------------------------------------------------------------------------- /PreviewImages/offsetPursuit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/offsetPursuit.gif -------------------------------------------------------------------------------- /PreviewImages/pursue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/pursue.gif -------------------------------------------------------------------------------- /PreviewImages/wallAvoid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/wallAvoid.gif -------------------------------------------------------------------------------- /PreviewImages/wander.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/PreviewImages/wander.gif -------------------------------------------------------------------------------- /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 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_DisableAudio: 0 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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: 2 7 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: .00499999989 11 | m_DefaultContactOffset: .00999999978 12 | m_SolverIterationCount: 6 13 | m_QueriesHitTriggers: 1 14 | m_EnableAdaptiveForce: 0 15 | m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 2 13 | m_SpritePackerPaddingPower: 1 14 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 15 | m_ProjectGenerationRootNamespace: 16 | -------------------------------------------------------------------------------- /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: 4 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_LegacyDeferred: 14 | m_Mode: 1 15 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 16 | m_AlwaysIncludedShaders: 17 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 18 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 19 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 20 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 21 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 22 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 23 | m_PreloadedShaders: [] 24 | m_LightmapStripping: 0 25 | m_LightmapKeepPlain: 1 26 | m_LightmapKeepDirCombined: 1 27 | m_LightmapKeepDirSeparate: 1 28 | m_LightmapKeepDynamicPlain: 1 29 | m_LightmapKeepDynamicDirCombined: 1 30 | m_LightmapKeepDynamicDirSeparate: 1 31 | m_FogStripping: 0 32 | m_FogKeepLinear: 1 33 | m_FogKeepExp: 1 34 | m_FogKeepExp2: 1 35 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshAreas: 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 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /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: 2 7 | m_Gravity: {x: 0, y: -9.81000042} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: .200000003 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_MinPenetrationForPenalty: .00999999978 17 | m_BaumgarteScale: .200000003 18 | m_BaumgarteTimeOfImpactScale: .75 19 | m_TimeToSleep: .5 20 | m_LinearSleepTolerance: .00999999978 21 | m_AngularSleepTolerance: 2 22 | m_QueriesHitTriggers: 1 23 | m_QueriesStartInColliders: 1 24 | m_ChangeStopsCallbacks: 0 25 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 26 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.1.0b10 2 | -------------------------------------------------------------------------------- /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: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 2 18 | shadowCascade2Split: .333333343 19 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 20 | blendWeights: 1 21 | textureQuality: 1 22 | anisotropicTextures: 0 23 | antiAliasing: 0 24 | softParticles: 0 25 | softVegetation: 0 26 | realtimeReflectionProbes: 0 27 | billboardsFaceCameraPosition: 0 28 | vSyncCount: 0 29 | lodBias: .300000012 30 | maximumLODLevel: 0 31 | particleRaycastBudget: 4 32 | excludedTargetPlatforms: [] 33 | - serializedVersion: 2 34 | name: Fast 35 | pixelLightCount: 0 36 | shadows: 0 37 | shadowResolution: 0 38 | shadowProjection: 1 39 | shadowCascades: 1 40 | shadowDistance: 20 41 | shadowNearPlaneOffset: 2 42 | shadowCascade2Split: .333333343 43 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 44 | blendWeights: 2 45 | textureQuality: 0 46 | anisotropicTextures: 0 47 | antiAliasing: 0 48 | softParticles: 0 49 | softVegetation: 0 50 | realtimeReflectionProbes: 0 51 | billboardsFaceCameraPosition: 0 52 | vSyncCount: 0 53 | lodBias: .400000006 54 | maximumLODLevel: 0 55 | particleRaycastBudget: 16 56 | excludedTargetPlatforms: [] 57 | - serializedVersion: 2 58 | name: Simple 59 | pixelLightCount: 1 60 | shadows: 1 61 | shadowResolution: 0 62 | shadowProjection: 1 63 | shadowCascades: 1 64 | shadowDistance: 20 65 | shadowNearPlaneOffset: 2 66 | shadowCascade2Split: .333333343 67 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 68 | blendWeights: 2 69 | textureQuality: 0 70 | anisotropicTextures: 1 71 | antiAliasing: 0 72 | softParticles: 0 73 | softVegetation: 0 74 | realtimeReflectionProbes: 0 75 | billboardsFaceCameraPosition: 0 76 | vSyncCount: 0 77 | lodBias: .699999988 78 | maximumLODLevel: 0 79 | particleRaycastBudget: 64 80 | excludedTargetPlatforms: [] 81 | - serializedVersion: 2 82 | name: Good 83 | pixelLightCount: 2 84 | shadows: 2 85 | shadowResolution: 1 86 | shadowProjection: 1 87 | shadowCascades: 2 88 | shadowDistance: 40 89 | shadowNearPlaneOffset: 2 90 | shadowCascade2Split: .333333343 91 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 92 | blendWeights: 2 93 | textureQuality: 0 94 | anisotropicTextures: 1 95 | antiAliasing: 0 96 | softParticles: 0 97 | softVegetation: 1 98 | realtimeReflectionProbes: 1 99 | billboardsFaceCameraPosition: 1 100 | vSyncCount: 1 101 | lodBias: 1 102 | maximumLODLevel: 0 103 | particleRaycastBudget: 256 104 | excludedTargetPlatforms: [] 105 | - serializedVersion: 2 106 | name: Beautiful 107 | pixelLightCount: 3 108 | shadows: 2 109 | shadowResolution: 2 110 | shadowProjection: 1 111 | shadowCascades: 2 112 | shadowDistance: 70 113 | shadowNearPlaneOffset: 2 114 | shadowCascade2Split: .333333343 115 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 116 | blendWeights: 4 117 | textureQuality: 0 118 | anisotropicTextures: 2 119 | antiAliasing: 2 120 | softParticles: 1 121 | softVegetation: 1 122 | realtimeReflectionProbes: 1 123 | billboardsFaceCameraPosition: 1 124 | vSyncCount: 1 125 | lodBias: 1.5 126 | maximumLODLevel: 0 127 | particleRaycastBudget: 1024 128 | excludedTargetPlatforms: [] 129 | - serializedVersion: 2 130 | name: Fantastic 131 | pixelLightCount: 4 132 | shadows: 2 133 | shadowResolution: 2 134 | shadowProjection: 1 135 | shadowCascades: 4 136 | shadowDistance: 150 137 | shadowNearPlaneOffset: 2 138 | shadowCascade2Split: .333333343 139 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 140 | blendWeights: 4 141 | textureQuality: 0 142 | anisotropicTextures: 2 143 | antiAliasing: 2 144 | softParticles: 1 145 | softVegetation: 1 146 | realtimeReflectionProbes: 1 147 | billboardsFaceCameraPosition: 1 148 | vSyncCount: 1 149 | lodBias: 2 150 | maximumLODLevel: 0 151 | particleRaycastBudget: 4096 152 | excludedTargetPlatforms: [] 153 | m_PerPlatformDefaultQuality: 154 | Android: 2 155 | BlackBerry: 2 156 | GLES Emulation: 5 157 | Nintendo 3DS: 5 158 | PS3: 5 159 | PS4: 5 160 | PSM: 5 161 | PSP2: 2 162 | Samsung TV: 2 163 | Standalone: 5 164 | Tizen: 2 165 | WP8: 5 166 | Web: 5 167 | WebGL: 3 168 | Wii U: 5 169 | Windows Store Apps: 5 170 | XBOX360: 5 171 | XboxOne: 5 172 | iPhone: 2 173 | -------------------------------------------------------------------------------- /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 | - 15 | - 16 | - Sensor 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 | -------------------------------------------------------------------------------- /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: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!292 &1 4 | UnityAdsSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_InitializeOnStartup: 1 8 | m_TestMode: 0 9 | m_EnabledPlatforms: 4294967295 10 | m_IosGameId: 11 | m_AndroidGameId: 12 | -------------------------------------------------------------------------------- /ProjectSettings/UnityAnalyticsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!303 &1 4 | UnityAnalyticsManager: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_InitializeOnStartup: 1 8 | m_TestMode: 0 9 | m_TestEventUrl: 10 | m_TestConfigUrl: 11 | -------------------------------------------------------------------------------- /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 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_Enabled: 0 14 | m_CaptureEditorExceptions: 1 15 | UnityPurchasingSettings: 16 | m_Enabled: 0 17 | m_TestMode: 0 18 | UnityAnalyticsSettings: 19 | m_Enabled: 0 20 | m_InitializeOnStartup: 1 21 | m_TestMode: 0 22 | m_TestEventUrl: 23 | m_TestConfigUrl: 24 | UnityAdsSettings: 25 | m_Enabled: 0 26 | m_InitializeOnStartup: 1 27 | m_TestMode: 0 28 | m_EnabledPlatforms: 4294967295 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Movement AI 2 | **Unity Movement AI** is a library of common movement AI scripts known as Steering Behaviors. You can use these scripts to help your NPCs move around your game. 3 | 4 | Currently the library only moves game objects in the x/y direction. 5 | 6 | # How to Use 7 | If you want to add this library to your game then import the [**unity-movement-ai.package**](https://github.com/antonpantev/unity-movement-ai/raw/master/unity-movement-ai.unitypackage). This package includes all of the movement scripts along with some premade game objects that use the scripts. 8 | 9 | Feel free to only use what you need from the package. 10 | 11 | #Examples 12 | If you would like to play around with the library then download this whole repository and open it in Unity. The **Examples** folder holds a number of premade scenes for you to play around with. 13 | 14 | #Additional Info 15 | The library comes with the following steering behaviors: 16 | `Arrive`, `Cohesion`, `Collision Avoidance`, `Evade`, `Flee`, `Follow Path`, `Hide`, `Interpose`, `Offset Pursuit`, `Pursue`, `Seek`, `Separation`, `Velocity Match`, `Wall Avoidance`, and `Wander`. 17 | 18 | Most steering behaviors have their own file, but `Arrive`, `Interpose`, and `Seek` are all located within the **SteeringBasics.cs** file. 19 | 20 | #Previews 21 | Here are some previews of the different movement AI that come with this library. 22 | 23 | ### Arrive 24 | 25 | 26 | ### Hide 27 | 28 | 29 | ### Flocking 30 | 31 | 32 | ### Wall Avoidance 33 | 34 | -------------------------------------------------------------------------------- /unity-movement-ai.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunGuangdong/unity-movement-ai/1aa3827377d17ebf4ab042e9d31d50a0299d23b1/unity-movement-ai.unitypackage --------------------------------------------------------------------------------