From ff89c370ef14d3050d71d975d2b0aa1f588779cf Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 14:03:33 +0300 Subject: [PATCH 1/9] VSCode settings file --- .vscode/settings.json | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5ec2335 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,55 @@ +{ + "files.exclude": + { + "**/.DS_Store":true, + "**/.git":true, + "**/.gitmodules":true, + "**/*.booproj":true, + "**/*.pidb":true, + "**/*.suo":true, + "**/*.user":true, + "**/*.userprefs":true, + "**/*.unityproj":true, + "**/*.dll":true, + "**/*.exe":true, + "**/*.pdf":true, + "**/*.mid":true, + "**/*.midi":true, + "**/*.wav":true, + "**/*.gif":true, + "**/*.ico":true, + "**/*.jpg":true, + "**/*.jpeg":true, + "**/*.png":true, + "**/*.psd":true, + "**/*.tga":true, + "**/*.tif":true, + "**/*.tiff":true, + "**/*.3ds":true, + "**/*.3DS":true, + "**/*.fbx":true, + "**/*.FBX":true, + "**/*.lxo":true, + "**/*.LXO":true, + "**/*.ma":true, + "**/*.MA":true, + "**/*.obj":true, + "**/*.OBJ":true, + "**/*.asset":true, + "**/*.cubemap":true, + "**/*.flare":true, + "**/*.mat":true, + "**/*.meta":true, + "**/*.prefab":true, + "**/*.unity":true, + "build/":true, + "Build/":true, + "Library/":true, + "library/":true, + "obj/":true, + "Obj/":true, + "ProjectSettings/":true, + "temp/":true, + "Temp/":true + } +} From 2295650e167587c92bbbcad601cf24a219a3b207 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 14:25:17 +0300 Subject: [PATCH 2/9] Movement and Pausable interfaces added --- Assets/Scripts/Movement.meta | 8 ++++++++ Assets/Scripts/Movement/IMovement.cs | 10 ++++++++++ Assets/Scripts/Movement/IMovement.cs.meta | 11 +++++++++++ Assets/Scripts/Pausable.meta | 8 ++++++++ Assets/Scripts/Pausable/IPausable.cs | 9 +++++++++ Assets/Scripts/Pausable/IPausable.cs.meta | 11 +++++++++++ 6 files changed, 57 insertions(+) create mode 100644 Assets/Scripts/Movement.meta create mode 100644 Assets/Scripts/Movement/IMovement.cs create mode 100644 Assets/Scripts/Movement/IMovement.cs.meta create mode 100644 Assets/Scripts/Pausable.meta create mode 100644 Assets/Scripts/Pausable/IPausable.cs create mode 100644 Assets/Scripts/Pausable/IPausable.cs.meta diff --git a/Assets/Scripts/Movement.meta b/Assets/Scripts/Movement.meta new file mode 100644 index 0000000..5fb133a --- /dev/null +++ b/Assets/Scripts/Movement.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bc70279699861044bb90fcb1700e5eaf +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Movement/IMovement.cs b/Assets/Scripts/Movement/IMovement.cs new file mode 100644 index 0000000..7fe1526 --- /dev/null +++ b/Assets/Scripts/Movement/IMovement.cs @@ -0,0 +1,10 @@ +using Pausable; + +namespace Movement +{ + public interface IMovement : IPausable + { + float BaseSpeed { get; set; } + void Move(int value); + } +} diff --git a/Assets/Scripts/Movement/IMovement.cs.meta b/Assets/Scripts/Movement/IMovement.cs.meta new file mode 100644 index 0000000..d82ccdb --- /dev/null +++ b/Assets/Scripts/Movement/IMovement.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7372c0f42c210d04f98b21e15803e940 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Pausable.meta b/Assets/Scripts/Pausable.meta new file mode 100644 index 0000000..ea16038 --- /dev/null +++ b/Assets/Scripts/Pausable.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a98c359db26a84941b48a708071cf618 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Pausable/IPausable.cs b/Assets/Scripts/Pausable/IPausable.cs new file mode 100644 index 0000000..c62a517 --- /dev/null +++ b/Assets/Scripts/Pausable/IPausable.cs @@ -0,0 +1,9 @@ +namespace Pausable +{ + public interface IPausable + { + bool IsPaused { get; } + void Pause(); + void Resume(); + } +} diff --git a/Assets/Scripts/Pausable/IPausable.cs.meta b/Assets/Scripts/Pausable/IPausable.cs.meta new file mode 100644 index 0000000..d6e2c96 --- /dev/null +++ b/Assets/Scripts/Pausable/IPausable.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: beb0150e245e8cc4cad614670be50ac8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 4fa1927fdc74e50471c1357ec9cd603a9fac1aff Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 14:29:21 +0300 Subject: [PATCH 3/9] Fixed the wrong type in the IMovement --- Assets/Scripts/Movement/IMovement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/Movement/IMovement.cs b/Assets/Scripts/Movement/IMovement.cs index 7fe1526..8e5cd29 100644 --- a/Assets/Scripts/Movement/IMovement.cs +++ b/Assets/Scripts/Movement/IMovement.cs @@ -5,6 +5,6 @@ namespace Movement public interface IMovement : IPausable { float BaseSpeed { get; set; } - void Move(int value); + void Move(float value); } } From 9d0df8367cb15389203a87efbf77c1836b3bc2a2 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 15:40:40 +0300 Subject: [PATCH 4/9] Enemy and Player layers added --- .../Packages/com.unity.connect.share/Settings.json | 10 +++++----- ProjectSettings/TagManager.asset | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ProjectSettings/Packages/com.unity.connect.share/Settings.json b/ProjectSettings/Packages/com.unity.connect.share/Settings.json index 55f05c7..d545ad5 100644 --- a/ProjectSettings/Packages/com.unity.connect.share/Settings.json +++ b/ProjectSettings/Packages/com.unity.connect.share/Settings.json @@ -1,7 +1,7 @@ { - "m_Name": "Settings", - "m_Path": "ProjectSettings/Packages/com.unity.connect.share/Settings.json", - "m_Dictionary": { - "m_DictionaryValues": [] - } + "m_Name": "Settings", + "m_Path": "ProjectSettings/Packages/com.unity.connect.share/Settings.json", + "m_Dictionary": { + "m_DictionaryValues": [] + } } \ No newline at end of file diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 1c92a78..091dcdd 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -11,8 +11,8 @@ TagManager: - - Water - UI - - - - + - Player + - Enemy - - - From 87f0652ce19097310babfb72ab55f590a1a21ae5 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 15:41:19 +0300 Subject: [PATCH 5/9] Prefabs Folder Added and BasicPatrollingEnemy Prefab Added --- Assets/Prefabs.meta | 8 ++ Assets/Prefabs/BasicPatrollingEnemy.prefab | 135 ++++++++++++++++++ .../Prefabs/BasicPatrollingEnemy.prefab.meta | 7 + 3 files changed, 150 insertions(+) create mode 100644 Assets/Prefabs.meta create mode 100644 Assets/Prefabs/BasicPatrollingEnemy.prefab create mode 100644 Assets/Prefabs/BasicPatrollingEnemy.prefab.meta diff --git a/Assets/Prefabs.meta b/Assets/Prefabs.meta new file mode 100644 index 0000000..e7a94fb --- /dev/null +++ b/Assets/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1b092a81799f77f4bb7c583b9aa0dcc7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/BasicPatrollingEnemy.prefab b/Assets/Prefabs/BasicPatrollingEnemy.prefab new file mode 100644 index 0000000..282032f --- /dev/null +++ b/Assets/Prefabs/BasicPatrollingEnemy.prefab @@ -0,0 +1,135 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7391517555913877016 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3234632762428300599} + - component: {fileID: 8510568918136408618} + - component: {fileID: 2564862039932993934} + - component: {fileID: 1030411162175245191} + m_Layer: 0 + m_Name: BasicPatrollingEnemy + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3234632762428300599 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.4136911, y: 0.5090097, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &8510568918136408618 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &2564862039932993934 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!50 &1030411162175245191 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 diff --git a/Assets/Prefabs/BasicPatrollingEnemy.prefab.meta b/Assets/Prefabs/BasicPatrollingEnemy.prefab.meta new file mode 100644 index 0000000..f618dbb --- /dev/null +++ b/Assets/Prefabs/BasicPatrollingEnemy.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c0a2079a443363b4da73a0d425221f6c +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 4cfbf23960235322adc31ed64543c395ec005304 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 15:53:23 +0300 Subject: [PATCH 6/9] Enemy Movement and BasicPatrollingEnemyAI has added --- Assets/Scripts/AI.meta | 8 + Assets/Scripts/AI/BasicPatrollingEnemyAI.cs | 58 ++++++ .../Scripts/AI/BasicPatrollingEnemyAI.cs.meta | 11 ++ Assets/Scripts/Movement/EnemyMovement.cs | 46 +++++ Assets/Scripts/Movement/EnemyMovement.cs.meta | 11 ++ ProjectSettings/SceneTemplateSettings.json | 167 ++++++++++++++++++ 6 files changed, 301 insertions(+) create mode 100644 Assets/Scripts/AI.meta create mode 100644 Assets/Scripts/AI/BasicPatrollingEnemyAI.cs create mode 100644 Assets/Scripts/AI/BasicPatrollingEnemyAI.cs.meta create mode 100644 Assets/Scripts/Movement/EnemyMovement.cs create mode 100644 Assets/Scripts/Movement/EnemyMovement.cs.meta create mode 100644 ProjectSettings/SceneTemplateSettings.json diff --git a/Assets/Scripts/AI.meta b/Assets/Scripts/AI.meta new file mode 100644 index 0000000..7d299ee --- /dev/null +++ b/Assets/Scripts/AI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d4e4f06743dc1be42806947cd62fb68e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs new file mode 100644 index 0000000..75be712 --- /dev/null +++ b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs @@ -0,0 +1,58 @@ +using Movement; +using UnityEngine; + +namespace AI +{ + public class BasicPatrollingEnemyAI : MonoBehaviour + { + [SerializeField] protected bool isMovingRight = false; + + [Space] + [Header("Left Detector")] + [SerializeField] protected Vector2 leftCliffDetectorOrigin = Vector2.left; + [SerializeField] protected Vector2 leftCliffDetectorSize = Vector2.one; + + [Space] + [Header("Right Detector")] + [SerializeField] protected Vector2 rightCliffDetectorOrigin = Vector2.right; + [SerializeField] protected Vector2 rightCliffDetectorSize = Vector2.one; + + [Space] + [Header("Right Detector")] + [SerializeField] protected LayerMask groundLayerMask = ~(1 << 6); // Everything except the "Player" layer + + protected IMovement movement = null; + protected Collider2D[] nonAllocColliderArray = new Collider2D[10]; + + protected Vector2 leftCliffPosition => GetCliffPositionInWorld(leftCliffDetectorOrigin); + protected Vector2 rightCliffPosition => GetCliffPositionInWorld(rightCliffDetectorOrigin); + + protected bool IsLeftDetectorCollided => Physics2D.OverlapBoxNonAlloc(leftCliffPosition, leftCliffDetectorSize, 0, nonAllocColliderArray, groundLayerMask) != 0; + protected bool IsRightDetectorCollided => Physics2D.OverlapBoxNonAlloc(rightCliffPosition, rightCliffDetectorSize, 0, nonAllocColliderArray, groundLayerMask) != 0; + + protected virtual void Awake() + { + movement = gameObject.AddComponent(); + } + + protected virtual void FixedUpdate() + { + if ((isMovingRight && !IsRightDetectorCollided) || (!isMovingRight && !IsLeftDetectorCollided)) + isMovingRight = !isMovingRight; + + movement.Move(isMovingRight ? 1f : -1f); + } + + protected Vector2 GetCliffPositionInWorld(Vector2 cliffPosition) + => cliffPosition + (Vector2)transform.position; + + protected virtual void OnDrawGizmosSelected() + { + Gizmos.color = IsLeftDetectorCollided ? Color.green : Color.red; + Gizmos.DrawWireCube(leftCliffPosition, leftCliffDetectorSize); + + Gizmos.color = IsRightDetectorCollided ? Color.green : Color.red; + Gizmos.DrawWireCube(rightCliffPosition, rightCliffDetectorSize); + } + } +} diff --git a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs.meta b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs.meta new file mode 100644 index 0000000..26dd4b0 --- /dev/null +++ b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 321c5495f0d597749bf29c3a2966aa4a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Movement/EnemyMovement.cs b/Assets/Scripts/Movement/EnemyMovement.cs new file mode 100644 index 0000000..433a433 --- /dev/null +++ b/Assets/Scripts/Movement/EnemyMovement.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace Movement +{ + [RequireComponent(typeof(Rigidbody2D))] + public class EnemyMovement : MonoBehaviour, IMovement + { + private Rigidbody2D _rigidbody2D = null; + private bool _isPaused = false; + private float moveValue = 0f; + + public float BaseSpeed { get; set; } = 1f; + public bool IsPaused => _isPaused; + + private void Awake() + => _rigidbody2D = GetComponent(); + + private void FixedUpdate() + { + if (IsPaused) + return; + + Vector2 velocity = _rigidbody2D.velocity; + velocity.x = moveValue; + _rigidbody2D.velocity = velocity; + } + + public void Move(float value) + => moveValue = value * BaseSpeed; + + public void Pause() + { + _isPaused = true; + UpdateRigidbody(); + } + + public void Resume() + { + _isPaused = false; + UpdateRigidbody(); + } + + private void UpdateRigidbody() + => _rigidbody2D.simulated = !_isPaused; + } +} diff --git a/Assets/Scripts/Movement/EnemyMovement.cs.meta b/Assets/Scripts/Movement/EnemyMovement.cs.meta new file mode 100644 index 0000000..f3cca92 --- /dev/null +++ b/Assets/Scripts/Movement/EnemyMovement.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4ae10931055aaa44d8c518e9efa3d034 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/SceneTemplateSettings.json b/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 0000000..6f3e60f --- /dev/null +++ b/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,167 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicMaterial", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "ignore": false, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + "newSceneOverride": 0 +} \ No newline at end of file From cd2f667f560c90f5563218aabc87b55474831250 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 16:27:23 +0300 Subject: [PATCH 7/9] Collission Checker has been Added and Basic Patrolling Enemy Updated to use the Checkers --- Assets/Prefabs/Basic Patrolling Enemy.prefab | 359 ++++++++++++++++++ ...eta => Basic Patrolling Enemy.prefab.meta} | 0 Assets/Prefabs/BasicPatrollingEnemy.prefab | 135 ------- Assets/Scripts/AI/BasicPatrollingEnemyAI.cs | 49 +-- Assets/Scripts/Movement/CollissionChecker.cs | 18 + .../Movement/CollissionChecker.cs.meta | 11 + 6 files changed, 406 insertions(+), 166 deletions(-) create mode 100644 Assets/Prefabs/Basic Patrolling Enemy.prefab rename Assets/Prefabs/{BasicPatrollingEnemy.prefab.meta => Basic Patrolling Enemy.prefab.meta} (100%) delete mode 100644 Assets/Prefabs/BasicPatrollingEnemy.prefab create mode 100644 Assets/Scripts/Movement/CollissionChecker.cs create mode 100644 Assets/Scripts/Movement/CollissionChecker.cs.meta diff --git a/Assets/Prefabs/Basic Patrolling Enemy.prefab b/Assets/Prefabs/Basic Patrolling Enemy.prefab new file mode 100644 index 0000000..1aefc16 --- /dev/null +++ b/Assets/Prefabs/Basic Patrolling Enemy.prefab @@ -0,0 +1,359 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1835766140300886803 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 334282908223700766} + m_Layer: 0 + m_Name: Collission Checkers + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &334282908223700766 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1835766140300886803} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 3171748321895642525} + - {fileID: 7648712865646313035} + - {fileID: 8757415820976640968} + - {fileID: 7155506815360630270} + m_Father: {fileID: 3234632762428300599} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &4544581046616649083 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7155506815360630270} + - component: {fileID: 5662617623326585126} + m_Layer: 0 + m_Name: Right Ground + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7155506815360630270 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4544581046616649083} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.8, y: -0.75, z: 0} + m_LocalScale: {x: 0.5, y: 0.5, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 334282908223700766} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5662617623326585126 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4544581046616649083} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 02e036b6321fff34cbd154fd665a8b23, type: 3} + m_Name: + m_EditorClassIdentifier: + LayerMask: + serializedVersion: 2 + m_Bits: 4294967103 +--- !u!1 &5991452379241120368 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8757415820976640968} + - component: {fileID: 7220208958583308284} + m_Layer: 0 + m_Name: Left Ground + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8757415820976640968 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5991452379241120368} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.8, y: -0.75, z: 0} + m_LocalScale: {x: 0.5, y: 0.5, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 334282908223700766} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7220208958583308284 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5991452379241120368} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 02e036b6321fff34cbd154fd665a8b23, type: 3} + m_Name: + m_EditorClassIdentifier: + LayerMask: + serializedVersion: 2 + m_Bits: 4294967103 +--- !u!1 &7391517555913877016 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3234632762428300599} + - component: {fileID: 8510568918136408618} + - component: {fileID: 2564862039932993934} + - component: {fileID: 1030411162175245191} + m_Layer: 0 + m_Name: Basic Patrolling Enemy + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3234632762428300599 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.4136911, y: 0.5090097, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 334282908223700766} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &8510568918136408618 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &2564862039932993934 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!50 &1030411162175245191 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391517555913877016} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!1 &7883981671222168568 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3171748321895642525} + - component: {fileID: 7670569826422979744} + m_Layer: 0 + m_Name: Left Wall + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3171748321895642525 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7883981671222168568} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.8, y: 0, z: 0} + m_LocalScale: {x: 0.5, y: 0.75, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 334282908223700766} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7670569826422979744 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7883981671222168568} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 02e036b6321fff34cbd154fd665a8b23, type: 3} + m_Name: + m_EditorClassIdentifier: + LayerMask: + serializedVersion: 2 + m_Bits: 4294967103 +--- !u!1 &7984300476647789986 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7648712865646313035} + - component: {fileID: 2338888552764836054} + m_Layer: 0 + m_Name: Right Wall + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7648712865646313035 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7984300476647789986} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.8, y: 0, z: 0} + m_LocalScale: {x: 0.5, y: 0.75, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 334282908223700766} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2338888552764836054 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7984300476647789986} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 02e036b6321fff34cbd154fd665a8b23, type: 3} + m_Name: + m_EditorClassIdentifier: + LayerMask: + serializedVersion: 2 + m_Bits: 4294967103 diff --git a/Assets/Prefabs/BasicPatrollingEnemy.prefab.meta b/Assets/Prefabs/Basic Patrolling Enemy.prefab.meta similarity index 100% rename from Assets/Prefabs/BasicPatrollingEnemy.prefab.meta rename to Assets/Prefabs/Basic Patrolling Enemy.prefab.meta diff --git a/Assets/Prefabs/BasicPatrollingEnemy.prefab b/Assets/Prefabs/BasicPatrollingEnemy.prefab deleted file mode 100644 index 282032f..0000000 --- a/Assets/Prefabs/BasicPatrollingEnemy.prefab +++ /dev/null @@ -1,135 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &7391517555913877016 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 3234632762428300599} - - component: {fileID: 8510568918136408618} - - component: {fileID: 2564862039932993934} - - component: {fileID: 1030411162175245191} - m_Layer: 0 - m_Name: BasicPatrollingEnemy - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &3234632762428300599 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7391517555913877016} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.4136911, y: 0.5090097, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &8510568918136408618 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7391517555913877016} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!61 &2564862039932993934 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7391517555913877016} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.5} - oldSize: {x: 1, y: 1} - newSize: {x: 1, y: 1} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 1, y: 1} - m_EdgeRadius: 0 ---- !u!50 &1030411162175245191 -Rigidbody2D: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7391517555913877016} - m_BodyType: 0 - m_Simulated: 1 - m_UseFullKinematicContacts: 0 - m_UseAutoMass: 0 - m_Mass: 1 - m_LinearDrag: 0 - m_AngularDrag: 0.05 - m_GravityScale: 1 - m_Material: {fileID: 0} - m_Interpolate: 0 - m_SleepingMode: 1 - m_CollisionDetection: 0 - m_Constraints: 0 diff --git a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs index 75be712..ffbb6ec 100644 --- a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs +++ b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs @@ -7,52 +7,39 @@ namespace AI { [SerializeField] protected bool isMovingRight = false; - [Space] - [Header("Left Detector")] - [SerializeField] protected Vector2 leftCliffDetectorOrigin = Vector2.left; - [SerializeField] protected Vector2 leftCliffDetectorSize = Vector2.one; - - [Space] - [Header("Right Detector")] - [SerializeField] protected Vector2 rightCliffDetectorOrigin = Vector2.right; - [SerializeField] protected Vector2 rightCliffDetectorSize = Vector2.one; - - [Space] - [Header("Right Detector")] - [SerializeField] protected LayerMask groundLayerMask = ~(1 << 6); // Everything except the "Player" layer - protected IMovement movement = null; - protected Collider2D[] nonAllocColliderArray = new Collider2D[10]; - protected Vector2 leftCliffPosition => GetCliffPositionInWorld(leftCliffDetectorOrigin); - protected Vector2 rightCliffPosition => GetCliffPositionInWorld(rightCliffDetectorOrigin); + protected CollissionChecker leftWallChecker = null; + protected CollissionChecker rightWallChecker = null; + protected CollissionChecker leftGroundChecker = null; + protected CollissionChecker rightGroundChecker = null; - protected bool IsLeftDetectorCollided => Physics2D.OverlapBoxNonAlloc(leftCliffPosition, leftCliffDetectorSize, 0, nonAllocColliderArray, groundLayerMask) != 0; - protected bool IsRightDetectorCollided => Physics2D.OverlapBoxNonAlloc(rightCliffPosition, rightCliffDetectorSize, 0, nonAllocColliderArray, groundLayerMask) != 0; + + // If moving Right, and either there's no more ground to move into or there is a wall at the Right side of the enemy OR + // If moving Left, and either there's no more ground to move into or there is a wall at the Left side of the enemy + // We should change directions + private bool ShouldChangeDirection + => (isMovingRight && (rightWallChecker.IsCollided || !rightGroundChecker.IsCollided)) || + (!isMovingRight && (leftWallChecker.IsCollided || !leftGroundChecker.IsCollided)); protected virtual void Awake() { movement = gameObject.AddComponent(); + leftWallChecker = GetCollissionCheckerOnChild("Collission Checkers/Left Wall"); + rightWallChecker = GetCollissionCheckerOnChild("Collission Checkers/Right Wall"); + leftGroundChecker = GetCollissionCheckerOnChild("Collission Checkers/Left Ground"); + rightGroundChecker = GetCollissionCheckerOnChild("Collission Checkers/Right Ground"); } protected virtual void FixedUpdate() { - if ((isMovingRight && !IsRightDetectorCollided) || (!isMovingRight && !IsLeftDetectorCollided)) + if (ShouldChangeDirection) isMovingRight = !isMovingRight; movement.Move(isMovingRight ? 1f : -1f); } - protected Vector2 GetCliffPositionInWorld(Vector2 cliffPosition) - => cliffPosition + (Vector2)transform.position; - - protected virtual void OnDrawGizmosSelected() - { - Gizmos.color = IsLeftDetectorCollided ? Color.green : Color.red; - Gizmos.DrawWireCube(leftCliffPosition, leftCliffDetectorSize); - - Gizmos.color = IsRightDetectorCollided ? Color.green : Color.red; - Gizmos.DrawWireCube(rightCliffPosition, rightCliffDetectorSize); - } + protected CollissionChecker GetCollissionCheckerOnChild(string childName) + => transform.Find(childName).GetComponent(); } } diff --git a/Assets/Scripts/Movement/CollissionChecker.cs b/Assets/Scripts/Movement/CollissionChecker.cs new file mode 100644 index 0000000..52cbef7 --- /dev/null +++ b/Assets/Scripts/Movement/CollissionChecker.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +namespace Movement +{ + public class CollissionChecker : MonoBehaviour + { + private Collider2D[] nonAllocColliderArray = new Collider2D[5]; + + public LayerMask LayerMask = ~((1 << 6) | (1 << 7)); // Everything except the "Player" and "Enemy" layer + public bool IsCollided => Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, 0, nonAllocColliderArray, LayerMask) != 0; + + public void OnDrawGizmosSelected() + { + Gizmos.color = IsCollided ? Color.green : Color.red; + Gizmos.DrawWireCube(transform.position, transform.localScale); + } + } +} diff --git a/Assets/Scripts/Movement/CollissionChecker.cs.meta b/Assets/Scripts/Movement/CollissionChecker.cs.meta new file mode 100644 index 0000000..dcaf224 --- /dev/null +++ b/Assets/Scripts/Movement/CollissionChecker.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02e036b6321fff34cbd154fd665a8b23 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 94709d996e9df1898f7c2341beea08fb65f862b0 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 16:29:12 +0300 Subject: [PATCH 8/9] Syntriax Dev Scene has been Added --- Assets/Scenes/SyntriaxDevScene.unity | 558 ++++++++++++++++++++++ Assets/Scenes/SyntriaxDevScene.unity.meta | 7 + 2 files changed, 565 insertions(+) create mode 100644 Assets/Scenes/SyntriaxDevScene.unity create mode 100644 Assets/Scenes/SyntriaxDevScene.unity.meta diff --git a/Assets/Scenes/SyntriaxDevScene.unity b/Assets/Scenes/SyntriaxDevScene.unity new file mode 100644 index 0000000..1915b4d --- /dev/null +++ b/Assets/Scenes/SyntriaxDevScene.unity @@ -0,0 +1,558 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1469379 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1469382} + - component: {fileID: 1469381} + - component: {fileID: 1469380} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1469380 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1469379} + m_Enabled: 1 +--- !u!20 &1469381 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1469379} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1469382 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1469379} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &94080043 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 94080047} + - component: {fileID: 94080046} + - component: {fileID: 94080045} + - component: {fileID: 94080044} + m_Layer: 0 + m_Name: Square (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!50 &94080044 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 94080043} + m_BodyType: 2 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!61 &94080045 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 94080043} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!212 &94080046 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 94080043} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_Color: {r: 0.122641504, g: 0.122641504, b: 0.122641504, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!4 &94080047 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 94080043} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.56, y: -0.87, z: 0} + m_LocalScale: {x: 4.2125, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &402588447 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 7391517555913877016, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + m_PrefabInstance: {fileID: 7535556967068246786} + m_PrefabAsset: {fileID: 0} +--- !u!114 &402588448 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 402588447} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 321c5495f0d597749bf29c3a2966aa4a, type: 3} + m_Name: + m_EditorClassIdentifier: + isMovingRight: 0 +--- !u!1 &1050669381 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1050669385} + - component: {fileID: 1050669384} + - component: {fileID: 1050669383} + - component: {fileID: 1050669382} + m_Layer: 0 + m_Name: Square (2) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!50 &1050669382 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1050669381} + m_BodyType: 2 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!61 &1050669383 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1050669381} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!212 &1050669384 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1050669381} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_Color: {r: 0.122641504, g: 0.122641504, b: 0.122641504, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!4 &1050669385 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1050669381} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 6.4, y: 0.13, z: 0} + m_LocalScale: {x: 4.2125, y: 3, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &7535556967068246786 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalPosition.x + value: 2.52 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalPosition.y + value: 0.684 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7155506815360630270, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalPosition.y + value: -0.85 + objectReference: {fileID: 0} + - target: {fileID: 7391517555913877016, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_Name + value: BasicPatrollingEnemy + objectReference: {fileID: 0} + - target: {fileID: 8757415820976640968, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_LocalPosition.y + value: -0.85 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} diff --git a/Assets/Scenes/SyntriaxDevScene.unity.meta b/Assets/Scenes/SyntriaxDevScene.unity.meta new file mode 100644 index 0000000..a9690bf --- /dev/null +++ b/Assets/Scenes/SyntriaxDevScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ed8116991ece7a54a839e864f8962fb6 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 51578e4130a241cc262d7a034626e1f63918583d Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Feb 2022 18:47:01 +0300 Subject: [PATCH 9/9] Typo Fixed --- Assets/Scripts/AI/BasicPatrollingEnemyAI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs index ffbb6ec..be9c228 100644 --- a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs +++ b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs @@ -18,7 +18,7 @@ namespace AI // If moving Right, and either there's no more ground to move into or there is a wall at the Right side of the enemy OR // If moving Left, and either there's no more ground to move into or there is a wall at the Left side of the enemy // We should change directions - private bool ShouldChangeDirection + protected bool ShouldChangeDirection => (isMovingRight && (rightWallChecker.IsCollided || !rightGroundChecker.IsCollided)) || (!isMovingRight && (leftWallChecker.IsCollided || !leftGroundChecker.IsCollided));