├── .gitattributes ├── .gitignore ├── README.md └── Target Scanner ├── Material ├── Blue_Mat.mat ├── GreyBlue_Mat.mat ├── GridBlue_01_Mat.mat ├── GridOrange_01_Mat.mat ├── GridWhite_01_Mat.mat └── Textures │ ├── Grid_01_BaseMap.png │ ├── Grid_01_Emissive.png │ ├── Grid_01_Normal.png │ └── Grid_02_BaseMap.png ├── Read Me.pdf ├── Scene └── Example.unity ├── Scripts └── TargetScanner.cs └── Temp └── TestPlayer.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.meta 52 | *.pidb.meta 53 | *.pdb.meta 54 | *.mdb.meta 55 | 56 | # Unity3D generated file on crash reports 57 | sysinfo.txt 58 | 59 | # Builds 60 | *.apk 61 | *.aab 62 | *.unitypackage 63 | *.app 64 | 65 | # Crashlytics generated file 66 | crashlytics-build.properties 67 | 68 | # Packed Addressables 69 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 70 | 71 | # Temporary auto-generated Android Assets 72 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 73 | /[Aa]ssets/[Ss]treamingAssets/aa/* 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity-Target-Scanner 2 | 3 | Target Scanner Script for Unity with features like Field of View, Hight Difference, Alert Zone 4 | 5 | Script Type - Base Class 6 | 7 | FEATURES :- 8 | 9 | Field of view 10 | Alert area 11 | Height difference 12 | View Obstacle 13 | Give Nearest target 14 | 15 | METHODS :- 16 | 17 | Update Method 18 | 19 | ShowGizmos(); 20 | 21 | Return Methods (Transform) 22 | 23 | GetTarget(); 24 | GetNearestTarget(); 25 | GetTargetList(); 26 | -------------------------------------------------------------------------------- /Target Scanner/Material/Blue_Mat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-272362022367997255 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 5 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 8 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: Blue_Mat 24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 25 | m_ValidKeywords: [] 26 | m_InvalidKeywords: [] 27 | m_LightmapFlags: 4 28 | m_EnableInstancingVariants: 0 29 | m_DoubleSidedGI: 0 30 | m_CustomRenderQueue: -1 31 | stringTagMap: 32 | RenderType: Opaque 33 | disabledShaderPasses: [] 34 | m_SavedProperties: 35 | serializedVersion: 3 36 | m_TexEnvs: 37 | - _BaseMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _BumpMap: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _DetailAlbedoMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _DetailMask: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _DetailNormalMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | - _EmissionMap: 58 | m_Texture: {fileID: 0} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | - _MainTex: 62 | m_Texture: {fileID: 0} 63 | m_Scale: {x: 1, y: 1} 64 | m_Offset: {x: 0, y: 0} 65 | - _MetallicGlossMap: 66 | m_Texture: {fileID: 0} 67 | m_Scale: {x: 1, y: 1} 68 | m_Offset: {x: 0, y: 0} 69 | - _OcclusionMap: 70 | m_Texture: {fileID: 0} 71 | m_Scale: {x: 1, y: 1} 72 | m_Offset: {x: 0, y: 0} 73 | - _ParallaxMap: 74 | m_Texture: {fileID: 0} 75 | m_Scale: {x: 1, y: 1} 76 | m_Offset: {x: 0, y: 0} 77 | - _SpecGlossMap: 78 | m_Texture: {fileID: 0} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | - unity_Lightmaps: 82 | m_Texture: {fileID: 0} 83 | m_Scale: {x: 1, y: 1} 84 | m_Offset: {x: 0, y: 0} 85 | - unity_LightmapsInd: 86 | m_Texture: {fileID: 0} 87 | m_Scale: {x: 1, y: 1} 88 | m_Offset: {x: 0, y: 0} 89 | - unity_ShadowMasks: 90 | m_Texture: {fileID: 0} 91 | m_Scale: {x: 1, y: 1} 92 | m_Offset: {x: 0, y: 0} 93 | m_Ints: [] 94 | m_Floats: 95 | - _AlphaClip: 0 96 | - _Blend: 0 97 | - _BumpScale: 1 98 | - _ClearCoatMask: 0 99 | - _ClearCoatSmoothness: 0 100 | - _Cull: 2 101 | - _Cutoff: 0.5 102 | - _DetailAlbedoMapScale: 1 103 | - _DetailNormalMapScale: 1 104 | - _DstBlend: 0 105 | - _EnvironmentReflections: 1 106 | - _GlossMapScale: 1 107 | - _Glossiness: 0.5 108 | - _GlossyReflections: 1 109 | - _Metallic: 0 110 | - _Mode: 0 111 | - _OcclusionStrength: 1 112 | - _Parallax: 0.02 113 | - _QueueOffset: 0 114 | - _ReceiveShadows: 1 115 | - _Smoothness: 0.5 116 | - _SmoothnessTextureChannel: 0 117 | - _SpecularHighlights: 1 118 | - _SrcBlend: 1 119 | - _Surface: 0 120 | - _UVSec: 0 121 | - _WorkflowMode: 1 122 | - _ZWrite: 1 123 | m_Colors: 124 | - _BaseColor: {r: 0.48507768, g: 0.67556465, b: 0.7830189, a: 1} 125 | - _Color: {r: 0.48507768, g: 0.6755646, b: 0.7830188, a: 1} 126 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 127 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 128 | m_BuildTextureStacks: [] 129 | -------------------------------------------------------------------------------- /Target Scanner/Material/GreyBlue_Mat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-6500655174697112917 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 5 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 8 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: GreyBlue_Mat 24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 25 | m_ValidKeywords: 26 | - _ENVIRONMENTREFLECTIONS_OFF 27 | m_InvalidKeywords: 28 | - _GLOSSYREFLECTIONS_OFF 29 | m_LightmapFlags: 4 30 | m_EnableInstancingVariants: 0 31 | m_DoubleSidedGI: 0 32 | m_CustomRenderQueue: -1 33 | stringTagMap: 34 | RenderType: Opaque 35 | disabledShaderPasses: [] 36 | m_SavedProperties: 37 | serializedVersion: 3 38 | m_TexEnvs: 39 | - _BaseMap: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _BumpMap: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _DetailAlbedoMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _DetailMask: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _DetailNormalMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | - _EmissionMap: 60 | m_Texture: {fileID: 0} 61 | m_Scale: {x: 1, y: 1} 62 | m_Offset: {x: 0, y: 0} 63 | - _MainTex: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | - _MetallicGlossMap: 68 | m_Texture: {fileID: 0} 69 | m_Scale: {x: 1, y: 1} 70 | m_Offset: {x: 0, y: 0} 71 | - _OcclusionMap: 72 | m_Texture: {fileID: 0} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | - _ParallaxMap: 76 | m_Texture: {fileID: 0} 77 | m_Scale: {x: 1, y: 1} 78 | m_Offset: {x: 0, y: 0} 79 | - _SpecGlossMap: 80 | m_Texture: {fileID: 0} 81 | m_Scale: {x: 1, y: 1} 82 | m_Offset: {x: 0, y: 0} 83 | - unity_Lightmaps: 84 | m_Texture: {fileID: 0} 85 | m_Scale: {x: 1, y: 1} 86 | m_Offset: {x: 0, y: 0} 87 | - unity_LightmapsInd: 88 | m_Texture: {fileID: 0} 89 | m_Scale: {x: 1, y: 1} 90 | m_Offset: {x: 0, y: 0} 91 | - unity_ShadowMasks: 92 | m_Texture: {fileID: 0} 93 | m_Scale: {x: 1, y: 1} 94 | m_Offset: {x: 0, y: 0} 95 | m_Ints: [] 96 | m_Floats: 97 | - _AlphaClip: 0 98 | - _Blend: 0 99 | - _BumpScale: 1 100 | - _ClearCoatMask: 0 101 | - _ClearCoatSmoothness: 0 102 | - _Cull: 2 103 | - _Cutoff: 0.5 104 | - _DetailAlbedoMapScale: 1 105 | - _DetailNormalMapScale: 1 106 | - _DstBlend: 0 107 | - _EnvironmentReflections: 0 108 | - _GlossMapScale: 1 109 | - _Glossiness: 0.477 110 | - _GlossyReflections: 0 111 | - _Metallic: 0 112 | - _Mode: 0 113 | - _OcclusionStrength: 1 114 | - _Parallax: 0.02 115 | - _QueueOffset: 0 116 | - _ReceiveShadows: 1 117 | - _Smoothness: 0.477 118 | - _SmoothnessTextureChannel: 0 119 | - _SpecularHighlights: 1 120 | - _SrcBlend: 1 121 | - _Surface: 0 122 | - _UVSec: 0 123 | - _WorkflowMode: 1 124 | - _ZWrite: 1 125 | m_Colors: 126 | - _BaseColor: {r: 0.5110952, g: 0.62652487, b: 0.6886792, a: 1} 127 | - _Color: {r: 0.51109517, g: 0.62652487, b: 0.6886792, a: 1} 128 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 129 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 130 | m_BuildTextureStacks: [] 131 | -------------------------------------------------------------------------------- /Target Scanner/Material/GridBlue_01_Mat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 8 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: GridBlue_01_Mat 11 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 12 | m_ValidKeywords: 13 | - _EMISSION 14 | - _NORMALMAP 15 | m_InvalidKeywords: [] 16 | m_LightmapFlags: 2 17 | m_EnableInstancingVariants: 0 18 | m_DoubleSidedGI: 0 19 | m_CustomRenderQueue: -1 20 | stringTagMap: 21 | RenderType: Opaque 22 | disabledShaderPasses: [] 23 | m_SavedProperties: 24 | serializedVersion: 3 25 | m_TexEnvs: 26 | - _BaseMap: 27 | m_Texture: {fileID: 2800000, guid: d1118dda59970a2449ee890fa247c4c5, type: 3} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0.004, y: 0} 30 | - _BumpMap: 31 | m_Texture: {fileID: 2800000, guid: c5c221ed57a3bf6488f8eba0db28a004, type: 3} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailAlbedoMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _DetailMask: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _DetailNormalMap: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _EmissionMap: 47 | m_Texture: {fileID: 2800000, guid: d4d6919451fe3e24388816386a6d15a4, type: 3} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _MainTex: 51 | m_Texture: {fileID: 2800000, guid: d1118dda59970a2449ee890fa247c4c5, type: 3} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0.004, y: 0} 54 | - _MetallicGlossMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | - _OcclusionMap: 59 | m_Texture: {fileID: 0} 60 | m_Scale: {x: 1, y: 1} 61 | m_Offset: {x: 0, y: 0} 62 | - _ParallaxMap: 63 | m_Texture: {fileID: 0} 64 | m_Scale: {x: 1, y: 1} 65 | m_Offset: {x: 0, y: 0} 66 | - _SpecGlossMap: 67 | m_Texture: {fileID: 0} 68 | m_Scale: {x: 1, y: 1} 69 | m_Offset: {x: 0, y: 0} 70 | - unity_Lightmaps: 71 | m_Texture: {fileID: 0} 72 | m_Scale: {x: 1, y: 1} 73 | m_Offset: {x: 0, y: 0} 74 | - unity_LightmapsInd: 75 | m_Texture: {fileID: 0} 76 | m_Scale: {x: 1, y: 1} 77 | m_Offset: {x: 0, y: 0} 78 | - unity_ShadowMasks: 79 | m_Texture: {fileID: 0} 80 | m_Scale: {x: 1, y: 1} 81 | m_Offset: {x: 0, y: 0} 82 | m_Ints: [] 83 | m_Floats: 84 | - _AlphaClip: 0 85 | - _Blend: 0 86 | - _BumpScale: 1 87 | - _ClearCoatMask: 0 88 | - _ClearCoatSmoothness: 0 89 | - _Cull: 2 90 | - _Cutoff: 0.5 91 | - _DetailAlbedoMapScale: 1 92 | - _DetailNormalMapScale: 1 93 | - _DstBlend: 0 94 | - _EnvironmentReflections: 1 95 | - _GlossMapScale: 1 96 | - _Glossiness: 0.477 97 | - _GlossyReflections: 1 98 | - _Metallic: 0 99 | - _Mode: 0 100 | - _OcclusionStrength: 0 101 | - _Parallax: 0.02 102 | - _QueueOffset: 0 103 | - _ReceiveShadows: 1 104 | - _Smoothness: 0.477 105 | - _SmoothnessTextureChannel: 0 106 | - _SpecularHighlights: 1 107 | - _SrcBlend: 1 108 | - _Surface: 0 109 | - _UVSec: 0 110 | - _WorkflowMode: 1 111 | - _ZWrite: 1 112 | m_Colors: 113 | - _BaseColor: {r: 0.27038085, g: 0.6601244, b: 0.8773585, a: 1} 114 | - _Color: {r: 0.27038082, g: 0.66012436, b: 0.8773585, a: 1} 115 | - _EmissionColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 116 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 117 | m_BuildTextureStacks: [] 118 | --- !u!114 &4889104241632654758 119 | MonoBehaviour: 120 | m_ObjectHideFlags: 11 121 | m_CorrespondingSourceObject: {fileID: 0} 122 | m_PrefabInstance: {fileID: 0} 123 | m_PrefabAsset: {fileID: 0} 124 | m_GameObject: {fileID: 0} 125 | m_Enabled: 1 126 | m_EditorHideFlags: 0 127 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 128 | m_Name: 129 | m_EditorClassIdentifier: 130 | version: 5 131 | -------------------------------------------------------------------------------- /Target Scanner/Material/GridOrange_01_Mat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 8 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: GridOrange_01_Mat 11 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 12 | m_ValidKeywords: 13 | - _EMISSION 14 | - _ENVIRONMENTREFLECTIONS_OFF 15 | - _NORMALMAP 16 | m_InvalidKeywords: 17 | - _GLOSSYREFLECTIONS_OFF 18 | m_LightmapFlags: 2 19 | m_EnableInstancingVariants: 0 20 | m_DoubleSidedGI: 0 21 | m_CustomRenderQueue: -1 22 | stringTagMap: 23 | RenderType: Opaque 24 | disabledShaderPasses: [] 25 | m_SavedProperties: 26 | serializedVersion: 3 27 | m_TexEnvs: 28 | - _BaseMap: 29 | m_Texture: {fileID: 2800000, guid: d9c0dd5cdac07b145be73329e489869a, type: 3} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0.004, y: 0} 32 | - _BumpMap: 33 | m_Texture: {fileID: 2800000, guid: c5c221ed57a3bf6488f8eba0db28a004, type: 3} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _DetailAlbedoMap: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _DetailMask: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _DetailNormalMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _EmissionMap: 49 | m_Texture: {fileID: 2800000, guid: d4d6919451fe3e24388816386a6d15a4, type: 3} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _MainTex: 53 | m_Texture: {fileID: 2800000, guid: d9c0dd5cdac07b145be73329e489869a, type: 3} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0.004, y: 0} 56 | - _MetallicGlossMap: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | - _OcclusionMap: 61 | m_Texture: {fileID: 0} 62 | m_Scale: {x: 1, y: 1} 63 | m_Offset: {x: 0, y: 0} 64 | - _ParallaxMap: 65 | m_Texture: {fileID: 0} 66 | m_Scale: {x: 1, y: 1} 67 | m_Offset: {x: 0, y: 0} 68 | - _SpecGlossMap: 69 | m_Texture: {fileID: 0} 70 | m_Scale: {x: 1, y: 1} 71 | m_Offset: {x: 0, y: 0} 72 | - unity_Lightmaps: 73 | m_Texture: {fileID: 0} 74 | m_Scale: {x: 1, y: 1} 75 | m_Offset: {x: 0, y: 0} 76 | - unity_LightmapsInd: 77 | m_Texture: {fileID: 0} 78 | m_Scale: {x: 1, y: 1} 79 | m_Offset: {x: 0, y: 0} 80 | - unity_ShadowMasks: 81 | m_Texture: {fileID: 0} 82 | m_Scale: {x: 1, y: 1} 83 | m_Offset: {x: 0, y: 0} 84 | m_Ints: [] 85 | m_Floats: 86 | - _AlphaClip: 0 87 | - _Blend: 0 88 | - _BumpScale: 1 89 | - _ClearCoatMask: 0 90 | - _ClearCoatSmoothness: 0 91 | - _Cull: 2 92 | - _Cutoff: 0.5 93 | - _DetailAlbedoMapScale: 1 94 | - _DetailNormalMapScale: 1 95 | - _DstBlend: 0 96 | - _EnvironmentReflections: 0 97 | - _GlossMapScale: 1 98 | - _Glossiness: 0.477 99 | - _GlossyReflections: 0 100 | - _Metallic: 0 101 | - _Mode: 0 102 | - _OcclusionStrength: 0 103 | - _Parallax: 0.02 104 | - _QueueOffset: 0 105 | - _ReceiveShadows: 1 106 | - _Smoothness: 0.477 107 | - _SmoothnessTextureChannel: 0 108 | - _SpecularHighlights: 1 109 | - _SrcBlend: 1 110 | - _Surface: 0 111 | - _UVSec: 0 112 | - _WorkflowMode: 1 113 | - _ZWrite: 1 114 | m_Colors: 115 | - _BaseColor: {r: 1, g: 0.5985916, b: 0, a: 1} 116 | - _Color: {r: 1, g: 0.5985916, b: 0, a: 1} 117 | - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} 118 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 119 | m_BuildTextureStacks: [] 120 | --- !u!114 &4628965128947302990 121 | MonoBehaviour: 122 | m_ObjectHideFlags: 11 123 | m_CorrespondingSourceObject: {fileID: 0} 124 | m_PrefabInstance: {fileID: 0} 125 | m_PrefabAsset: {fileID: 0} 126 | m_GameObject: {fileID: 0} 127 | m_Enabled: 1 128 | m_EditorHideFlags: 0 129 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 130 | m_Name: 131 | m_EditorClassIdentifier: 132 | version: 5 133 | -------------------------------------------------------------------------------- /Target Scanner/Material/GridWhite_01_Mat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-5788133031919579493 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 5 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 8 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: GridWhite_01_Mat 24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 25 | m_ValidKeywords: 26 | - _EMISSION 27 | - _ENVIRONMENTREFLECTIONS_OFF 28 | - _NORMALMAP 29 | m_InvalidKeywords: 30 | - _GLOSSYREFLECTIONS_OFF 31 | m_LightmapFlags: 2 32 | m_EnableInstancingVariants: 0 33 | m_DoubleSidedGI: 0 34 | m_CustomRenderQueue: -1 35 | stringTagMap: 36 | RenderType: Opaque 37 | disabledShaderPasses: [] 38 | m_SavedProperties: 39 | serializedVersion: 3 40 | m_TexEnvs: 41 | - _BaseMap: 42 | m_Texture: {fileID: 2800000, guid: d9c0dd5cdac07b145be73329e489869a, type: 3} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0.004, y: 0} 45 | - _BumpMap: 46 | m_Texture: {fileID: 2800000, guid: c5c221ed57a3bf6488f8eba0db28a004, type: 3} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _DetailAlbedoMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _DetailMask: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | - _DetailNormalMap: 58 | m_Texture: {fileID: 0} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | - _EmissionMap: 62 | m_Texture: {fileID: 2800000, guid: d4d6919451fe3e24388816386a6d15a4, type: 3} 63 | m_Scale: {x: 1, y: 1} 64 | m_Offset: {x: 0, y: 0} 65 | - _MainTex: 66 | m_Texture: {fileID: 2800000, guid: d9c0dd5cdac07b145be73329e489869a, type: 3} 67 | m_Scale: {x: 1, y: 1} 68 | m_Offset: {x: 0.004, y: 0} 69 | - _MetallicGlossMap: 70 | m_Texture: {fileID: 0} 71 | m_Scale: {x: 1, y: 1} 72 | m_Offset: {x: 0, y: 0} 73 | - _OcclusionMap: 74 | m_Texture: {fileID: 0} 75 | m_Scale: {x: 1, y: 1} 76 | m_Offset: {x: 0, y: 0} 77 | - _ParallaxMap: 78 | m_Texture: {fileID: 0} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | - _SpecGlossMap: 82 | m_Texture: {fileID: 0} 83 | m_Scale: {x: 1, y: 1} 84 | m_Offset: {x: 0, y: 0} 85 | - unity_Lightmaps: 86 | m_Texture: {fileID: 0} 87 | m_Scale: {x: 1, y: 1} 88 | m_Offset: {x: 0, y: 0} 89 | - unity_LightmapsInd: 90 | m_Texture: {fileID: 0} 91 | m_Scale: {x: 1, y: 1} 92 | m_Offset: {x: 0, y: 0} 93 | - unity_ShadowMasks: 94 | m_Texture: {fileID: 0} 95 | m_Scale: {x: 1, y: 1} 96 | m_Offset: {x: 0, y: 0} 97 | m_Ints: [] 98 | m_Floats: 99 | - _AlphaClip: 0 100 | - _Blend: 0 101 | - _BumpScale: 1 102 | - _ClearCoatMask: 0 103 | - _ClearCoatSmoothness: 0 104 | - _Cull: 2 105 | - _Cutoff: 0.5 106 | - _DetailAlbedoMapScale: 1 107 | - _DetailNormalMapScale: 1 108 | - _DstBlend: 0 109 | - _EnvironmentReflections: 0 110 | - _GlossMapScale: 1 111 | - _Glossiness: 0.477 112 | - _GlossyReflections: 0 113 | - _Metallic: 0 114 | - _Mode: 0 115 | - _OcclusionStrength: 0 116 | - _Parallax: 0.02 117 | - _QueueOffset: 0 118 | - _ReceiveShadows: 1 119 | - _Smoothness: 0.477 120 | - _SmoothnessTextureChannel: 0 121 | - _SpecularHighlights: 1 122 | - _SrcBlend: 1 123 | - _Surface: 0 124 | - _UVSec: 0 125 | - _WorkflowMode: 1 126 | - _ZWrite: 1 127 | m_Colors: 128 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 129 | - _Color: {r: 1, g: 1, b: 1, a: 1} 130 | - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} 131 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 132 | m_BuildTextureStacks: [] 133 | -------------------------------------------------------------------------------- /Target Scanner/Material/Textures/Grid_01_BaseMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaibhavdevstuff/Unity-Target-Scanner/fe1d01a57b6a0537338032fab53c3f8890177e56/Target Scanner/Material/Textures/Grid_01_BaseMap.png -------------------------------------------------------------------------------- /Target Scanner/Material/Textures/Grid_01_Emissive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaibhavdevstuff/Unity-Target-Scanner/fe1d01a57b6a0537338032fab53c3f8890177e56/Target Scanner/Material/Textures/Grid_01_Emissive.png -------------------------------------------------------------------------------- /Target Scanner/Material/Textures/Grid_01_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaibhavdevstuff/Unity-Target-Scanner/fe1d01a57b6a0537338032fab53c3f8890177e56/Target Scanner/Material/Textures/Grid_01_Normal.png -------------------------------------------------------------------------------- /Target Scanner/Material/Textures/Grid_02_BaseMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaibhavdevstuff/Unity-Target-Scanner/fe1d01a57b6a0537338032fab53c3f8890177e56/Target Scanner/Material/Textures/Grid_02_BaseMap.png -------------------------------------------------------------------------------- /Target Scanner/Read Me.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaibhavdevstuff/Unity-Target-Scanner/fe1d01a57b6a0537338032fab53c3f8890177e56/Target Scanner/Read Me.pdf -------------------------------------------------------------------------------- /Target Scanner/Scripts/TargetScanner.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace DC.Scanner 5 | { 6 | 7 | [System.Serializable] 8 | public class TargetScanner 9 | { 10 | 11 | #region Variables 12 | 13 | [Tooltip("Center of Scanner")] 14 | [SerializeField] bool ScannerGizmos; 15 | [Tooltip("Center of Scanner")] 16 | [SerializeField] Transform transform; 17 | [Tooltip("Radius within which scanner will always detect Target")] 18 | [SerializeField] private float alertRadius = 1f; 19 | [Tooltip("Detection Radius of the Scanner")] 20 | [SerializeField] private float viewRadius = 5f; 21 | [Tooltip("Field Of View of the Scanner")] 22 | [Range(0f, 360f)] 23 | [SerializeField] private float viewAngle = 60f; 24 | [Tooltip("Layer of Target")] 25 | [SerializeField] private LayerMask targetLayer; 26 | [Tooltip("Layer of objects which Scanner should not see through")] 27 | [SerializeField] private LayerMask obstacleLayer; 28 | [SerializeField] private float heightOffset = 0; 29 | [Tooltip("Max Height Detection Range, Detect both Upward & Downward")] 30 | [SerializeField] private float maxHeightDifference = 1f; 31 | 32 | private List targetList = new List(); 33 | private Vector3 eyePos; 34 | private RaycastHit hit; 35 | private Transform customtarget; 36 | 37 | #endregion 38 | 39 | #region Getters & Setters 40 | 41 | public float ViewRadius { get { return viewRadius; } set { viewRadius = value; } } 42 | public float ViewAngle { get { return viewAngle; } set { viewAngle = value; } } 43 | public LayerMask TargetLayer { get { return targetLayer; } set { targetLayer = value; } } 44 | public LayerMask ObstacleLayer { get { return obstacleLayer; } set { obstacleLayer = value; } } 45 | public List TargetList { get { return targetList; } } 46 | public float HeightOffset { get { return heightOffset; } set { heightOffset = value; } } 47 | public float MaxHeightDifference { get { return maxHeightDifference; } set { maxHeightDifference = value; } } 48 | 49 | #endregion 50 | 51 | private void RunScanner() 52 | { 53 | if (!transform) 54 | { 55 | Debug.LogError("transform(Center of Scanner) not assigned"); 56 | return; 57 | } 58 | 59 | eyePos = transform.position + Vector3.up * heightOffset; 60 | 61 | FindVisibleTargets(); 62 | RemoveTargetFromList(); 63 | AddCustomtargetToList(); 64 | } 65 | 66 | /// 67 | /// Find the target within the view radius and store in List of Transform if follows particular paramerters 68 | /// 69 | private void FindVisibleTargets() 70 | { 71 | Collider[] targetsInViewRadius = Physics.OverlapSphere(transform.position, viewRadius, targetLayer); 72 | 73 | for (int i = 0; i < targetsInViewRadius.Length; i++) 74 | { 75 | Vector3 targetSize = targetsInViewRadius[i].bounds.size; 76 | Transform target = targetsInViewRadius[i].transform; 77 | 78 | Vector3 toPlayer = target.transform.position - eyePos; 79 | 80 | if (Mathf.Abs(toPlayer.y + heightOffset) > maxHeightDifference) 81 | { 82 | return; 83 | } 84 | 85 | if (Vector3.Distance(transform.position, target.position) < alertRadius) 86 | { 87 | if (!targetList.Contains(target)) 88 | targetList.Add(target); 89 | 90 | continue; 91 | } 92 | 93 | 94 | 95 | Vector3 dirToTarget = (target.position - transform.position).normalized; 96 | 97 | //Detect if any Obstacle come in path 98 | if (Vector3.Angle(transform.forward, dirToTarget) < viewAngle / 2) 99 | { 100 | targetSize.y -= 0.05f; //---------Manual offset in size so that raycast won't go above the mesh 101 | 102 | float offsetX = targetSize.x / 2; 103 | float offsetY = targetSize.y / 2; 104 | 105 | int rayCastIteration = 0; 106 | 107 | for (int j = 0; j < 3; j++) //----------Row of RayCast 108 | { 109 | for (int k = 0; k < 5; k++) //----------Column of RayCast 110 | { 111 | Vector3 targetPosition = target.position + new Vector3(offsetX, offsetY, 0); 112 | 113 | float distToTarget = Vector3.Distance(transform.position, target.position); 114 | 115 | dirToTarget = (targetPosition - transform.position).normalized; 116 | 117 | if (!Physics.Raycast(transform.position, dirToTarget, out hit, distToTarget, obstacleLayer)) 118 | { 119 | #if UNITY_EDITOR 120 | if (ScannerGizmos) 121 | Debug.DrawLine(transform.position, targetPosition, Color.green);//----------------------------------------------Debug RayCast 122 | #endif 123 | 124 | if (!targetList.Contains(target)) 125 | { 126 | targetList.Add(target); 127 | } 128 | 129 | goto EndOfLoop; //---------Target is detected no need to go further, so jump out of the Main loop 130 | } 131 | else 132 | { 133 | #if UNITY_EDITOR 134 | if (ScannerGizmos) 135 | Debug.DrawLine(transform.position, targetPosition, Color.red);//----------------------------------------------Debug RayCast 136 | #endif 137 | } 138 | 139 | offsetY -= targetSize.y / 4; 140 | } 141 | 142 | rayCastIteration++; 143 | offsetY = targetSize.y / 2; 144 | offsetX -= targetSize.x / 2; 145 | 146 | } 147 | 148 | if (rayCastIteration >= 3 && targetList.Contains(target)) 149 | { 150 | targetList.Remove(target); 151 | } 152 | 153 | } 154 | 155 | EndOfLoop:; 156 | } 157 | 158 | 159 | 160 | } 161 | 162 | /// 163 | /// Remove Targets which are not in Range 164 | /// 165 | private void RemoveTargetFromList() 166 | { 167 | if (targetList.Count == 0) return; 168 | 169 | for (int i = 0; i < targetList.Count; i++) 170 | { 171 | Transform target = targetList[i]; 172 | 173 | //Null Check--------------------------------------------- 174 | if (target == null) 175 | { 176 | targetList.RemoveAt(i); 177 | } 178 | 179 | //not active in hierarchy 180 | if (!target.gameObject.activeInHierarchy) 181 | { 182 | targetList.Remove(target); 183 | continue; 184 | } 185 | 186 | //Out of View Radius--------------------------------------------- 187 | if (Vector3.Distance(transform.position, target.position) > viewRadius) 188 | { 189 | targetList.Remove(target); 190 | continue; 191 | } 192 | 193 | //Inside Alert Radius--------------------------------------------- 194 | if (Vector3.Distance(transform.position, target.position) < alertRadius) continue; 195 | 196 | //HeightCheck--------------------------------------------- 197 | Vector3 toPlayer = target.transform.position - eyePos; 198 | if (Mathf.Abs(toPlayer.y + heightOffset) > maxHeightDifference) 199 | { 200 | targetList.Remove(target); 201 | } 202 | 203 | //Out of FOV--------------------------------------------- 204 | Vector3 dirToTarget = (target.position - transform.position).normalized; 205 | 206 | if (Vector3.Angle(transform.forward, dirToTarget) > viewAngle / 2) 207 | { 208 | targetList.Remove(target); 209 | } 210 | 211 | 212 | } 213 | 214 | } 215 | 216 | /// 217 | /// Add Custom target to the target List 218 | /// 219 | private void AddCustomtargetToList() 220 | { 221 | if (customtarget != null) 222 | { 223 | targetList.Add(customtarget); 224 | customtarget = null; 225 | } 226 | } 227 | 228 | /// 229 | /// Add Target to Scanner List (will be remove after one iteration if not fullfill scanner detection data) 230 | /// 231 | /// 232 | /// True: If not already present in Target List (will added in list after) 233 | public bool AddTarget(Transform CustomTarget) 234 | { 235 | if (!targetList.Contains(CustomTarget)) 236 | { 237 | customtarget = CustomTarget; 238 | return true; 239 | } 240 | else 241 | return false; 242 | 243 | } 244 | 245 | /// 246 | /// Give the first detected target by scanner 247 | /// 248 | public Transform GetTarget() 249 | { 250 | RunScanner(); 251 | 252 | if (targetList.Count == 0) return null; 253 | 254 | return targetList[0]; 255 | } 256 | 257 | /// 258 | /// Give the nearest target among all detected targets by scanner 259 | /// 260 | public Transform GetNearestTarget() 261 | { 262 | RunScanner(); 263 | 264 | if (targetList.Count == 0) return null; 265 | 266 | Transform _nearestTargetPos; 267 | 268 | _nearestTargetPos = targetList[0]; 269 | 270 | for (int i = 0; i < targetList.Count; i++) 271 | { 272 | if (Vector3.Distance(transform.position, targetList[i].position) < 273 | Vector3.Distance(transform.position, _nearestTargetPos.position)) 274 | { 275 | _nearestTargetPos = targetList[i]; 276 | } 277 | 278 | } 279 | 280 | return _nearestTargetPos; 281 | } 282 | 283 | /// 284 | /// Give the List of targets detected by scanner 285 | /// 286 | public List GetTargetList() 287 | { 288 | RunScanner(); 289 | 290 | if (targetList.Count == 0) return null; 291 | 292 | return targetList; 293 | } 294 | 295 | /// 296 | /// Show Gizmos of scanner 297 | /// 298 | public void ShowGizmos() 299 | { 300 | 301 | #if UNITY_EDITOR 302 | 303 | if (!ScannerGizmos || transform == null) return; 304 | 305 | Gizmos.color = Color.red; 306 | 307 | if (hit.collider != null) Gizmos.DrawSphere(hit.point, 0.15f); 308 | 309 | //Eye Location 310 | Gizmos.color = Color.yellow; 311 | Gizmos.DrawWireSphere(transform.position + Vector3.up * heightOffset, 0.2f); 312 | 313 | //Height Check Area 314 | UnityEditor.Handles.color = Color.yellow; 315 | UnityEditor.Handles.DrawWireDisc(transform.position + Vector3.up * maxHeightDifference, Vector3.up, viewRadius); 316 | UnityEditor.Handles.DrawWireDisc(transform.position + Vector3.down * maxHeightDifference, Vector3.up, viewRadius); 317 | 318 | //Always Detect Radius 319 | Color r = new Color(0.5f, 0f, 0f, 0.5f); 320 | UnityEditor.Handles.color = r; 321 | UnityEditor.Handles.DrawSolidArc(transform.position, Vector3.up, Vector3.forward, 360f, alertRadius); 322 | 323 | //View Radius 324 | UnityEditor.Handles.color = Color.white; 325 | UnityEditor.Handles.DrawWireDisc(transform.position, Vector3.up, viewRadius); 326 | 327 | //View Angle 328 | Color b = new Color(0, 0.5f, 0.7f, 0.2f); 329 | UnityEditor.Handles.color = b; 330 | Vector3 rotatedForward = Quaternion.Euler(0, -viewAngle * 0.5f, 0) * transform.forward; 331 | UnityEditor.Handles.DrawSolidArc(transform.position, Vector3.up, rotatedForward, viewAngle, viewRadius); 332 | 333 | //To Target Line 334 | Gizmos.color = Color.red; 335 | foreach (Transform t in targetList) 336 | { 337 | Gizmos.DrawLine(transform.position, t.position); 338 | Gizmos.DrawCube(t.position, new Vector3(0.3f, 0.3f, 0.3f)); 339 | } 340 | 341 | #endif 342 | 343 | 344 | } 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | }//class 369 | } -------------------------------------------------------------------------------- /Target Scanner/Temp/TestPlayer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using DC.Scanner; 5 | 6 | namespace DC.Test 7 | { 8 | 9 | public class TestPlayer : MonoBehaviour 10 | { 11 | public TargetScanner scanner; 12 | 13 | Transform pos; 14 | 15 | // Update is called once per frame 16 | void FixedUpdate() 17 | { 18 | pos = scanner.GetNearestTarget(); 19 | 20 | } 21 | 22 | private void OnDrawGizmos() 23 | { 24 | scanner.ShowGizmos(); 25 | } 26 | } 27 | 28 | } 29 | --------------------------------------------------------------------------------