From 256036c17e80415c2816ea852021de3b92ab9cf8 Mon Sep 17 00:00:00 2001 From: "aube.lee" Date: Thu, 20 Feb 2025 11:07:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=BA=90=EB=A6=AD=ED=84=B0=EA=B0=80=20?= =?UTF-8?q?=EB=B2=BD=EC=97=90=20=EC=B6=A9=EB=8F=8C=ED=96=88=EC=9D=84?= =?UTF-8?q?=EB=95=8C=20=EC=B6=94=EB=9D=BD=ED=95=98=EA=B2=8C=20=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/Player/TON.Player_B.prefab | 172 ++++++++++++++++-- .../Resources/Player/TON.Player_W.prefab | 168 +++++++++++++++-- .../Scripts/Character/CharacterBase.cs | 112 +++++++----- .../Gameton/Scripts/Character/WallChecker.cs | 24 +++ .../Scripts/Character/WallChecker.cs.meta | 11 ++ 5 files changed, 402 insertions(+), 85 deletions(-) create mode 100644 Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs create mode 100644 Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs.meta diff --git a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab index 8de6e61a..6c01de3b 100644 --- a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab +++ b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab @@ -1,5 +1,129 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &1683425442026523196 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 427864611187260801} + m_Layer: 0 + m_Name: Ground Check + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &427864611187260801 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1683425442026523196} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.01, y: 0.04, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 8528093570479225059} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2164958371881100909 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1793695631517267361} + - component: {fileID: 780589065329392038} + - component: {fileID: 6824007025137790925} + m_Layer: 0 + m_Name: Wall Checker + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1793695631517267361 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2164958371881100909} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.0092, y: 0.1483, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 8528093570479225059} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!61 &780589065329392038 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2164958371881100909} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 1 + 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, y: 0} + oldSize: {x: 0, y: 0} + newSize: {x: 0, y: 0} + adaptiveTilingThreshold: 0 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 0.25, y: 0.15} + m_EdgeRadius: 0 +--- !u!114 &6824007025137790925 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2164958371881100909} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 75a6dd00ee9c3d7428cae5700b2cc666, type: 3} + m_Name: + m_EditorClassIdentifier: + groundLayer: + serializedVersion: 2 + m_Bits: 512 --- !u!1 &2757306338607502731 GameObject: m_ObjectHideFlags: 0 @@ -42,7 +166,7 @@ GameObject: - component: {fileID: 8528093570479225059} - component: {fileID: 6967183450965278935} - component: {fileID: 8059802051760727483} - - component: {fileID: 880817811453911241} + - component: {fileID: 292703337309736025} - component: {fileID: 4986202531950816680} - component: {fileID: 2392205422319772847} - component: {fileID: 7649288990551335566} @@ -62,12 +186,14 @@ Transform: m_GameObject: {fileID: 3656570700648378249} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.36, y: -1.5, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 5, y: 5, z: 0} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 3571909985532505043} - {fileID: 6308497305587874648} + - {fileID: 427864611187260801} + - {fileID: 1793695631517267361} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &6967183450965278935 @@ -143,8 +269,8 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 ---- !u!61 &880817811453911241 -BoxCollider2D: +--- !u!70 &292703337309736025 +CapsuleCollider2D: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -175,19 +301,9 @@ BoxCollider2D: m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 - m_Offset: {x: -0.015000001, y: 0.13} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.6, y: -0.21052632} - oldSize: {x: 0.15, y: 0.19} - newSize: {x: 0.2, y: 0.2} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 0.13, y: 0.18} - m_EdgeRadius: 0 + m_Offset: {x: -0.01, y: 0.135} + m_Size: {x: 0.12, y: 0.18} + m_Direction: 0 --- !u!50 &4986202531950816680 Rigidbody2D: serializedVersion: 4 @@ -242,15 +358,31 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 163a5df0eeadca842adba0310b08b93e, type: 3} m_Name: m_EditorClassIdentifier: + playerData: + id: + type: + name: + level: 0 + experience: 0 + hp: 0 + mp: 0 + attackPower: 0 + defensivePower: 0 + critical: 0 currentHP: 0 - maxHP: 0 currentSP: 0 - maxSP: 0 speed: 3 jumpForce: 8 + airControl: 0.8 + sideCheckDistance: 0.5 + groundCheck: {fileID: 427864611187260801} + groundCheckRadius: 0.1 + groundLayer: + serializedVersion: 2 + m_Bits: 512 + wallChecker: {fileID: 6824007025137790925} firePoint: {fileID: 3571909985532505043} attackCollider: {fileID: 3772826248857896723} - animator: {fileID: 0} rb: {fileID: 4986202531950816680} --- !u!1 &6930308287002930140 GameObject: diff --git a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab index b554e1d8..f3e39d7a 100644 --- a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab +++ b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab @@ -1,5 +1,126 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &946989082622396807 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 777487253851638430} + m_Layer: 0 + m_Name: Ground Check + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &777487253851638430 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 946989082622396807} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.01, y: 0.04, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 8528093570479225059} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1886314844740901613 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4803398892385748894} + - component: {fileID: 2394062811346782473} + - component: {fileID: 6530647677844077835} + m_Layer: 0 + m_Name: Wall Checker + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4803398892385748894 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1886314844740901613} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.0092, y: 0.1483, z: 0} + m_LocalScale: {x: 1, y: 1, z: 0} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 8528093570479225059} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!61 &2394062811346782473 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1886314844740901613} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 1 + 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, y: 0} + oldSize: {x: 0, y: 0} + newSize: {x: 0, y: 0} + adaptiveTilingThreshold: 0 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 0.25, y: 0.15} + m_EdgeRadius: 0 +--- !u!114 &6530647677844077835 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1886314844740901613} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 75a6dd00ee9c3d7428cae5700b2cc666, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &3656570700648378249 GameObject: m_ObjectHideFlags: 0 @@ -11,7 +132,7 @@ GameObject: - component: {fileID: 8528093570479225059} - component: {fileID: 6967183450965278935} - component: {fileID: 8059802051760727483} - - component: {fileID: 880817811453911241} + - component: {fileID: 258578364601596647} - component: {fileID: 4986202531950816680} - component: {fileID: 2392205422319772847} - component: {fileID: 7649288990551335566} @@ -31,12 +152,14 @@ Transform: m_GameObject: {fileID: 3656570700648378249} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.36, y: -1.5, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 5, y: 5, z: 0} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 3204799031628172313} - {fileID: 548404723012153258} + - {fileID: 777487253851638430} + - {fileID: 4803398892385748894} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &6967183450965278935 @@ -112,8 +235,8 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 ---- !u!61 &880817811453911241 -BoxCollider2D: +--- !u!70 &258578364601596647 +CapsuleCollider2D: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -144,19 +267,9 @@ BoxCollider2D: m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 - m_Offset: {x: -0.015000001, y: 0.13} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.6, y: -0.21052632} - oldSize: {x: 0.15, y: 0.19} - newSize: {x: 0.2, y: 0.2} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 0.13, y: 0.18} - m_EdgeRadius: 0 + m_Offset: {x: -0.01, y: 0.135} + m_Size: {x: 0.12, y: 0.18} + m_Direction: 0 --- !u!50 &4986202531950816680 Rigidbody2D: serializedVersion: 4 @@ -211,15 +324,30 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 163a5df0eeadca842adba0310b08b93e, type: 3} m_Name: m_EditorClassIdentifier: + playerData: + id: + type: + name: + level: 0 + experience: 0 + hp: 0 + mp: 0 + attackPower: 0 + defensivePower: 0 + critical: 0 currentHP: 0 - maxHP: 0 currentSP: 0 - maxSP: 0 speed: 3 jumpForce: 8 + airControl: 0.8 + groundCheck: {fileID: 777487253851638430} + groundCheckRadius: 0.15 + groundLayer: + serializedVersion: 2 + m_Bits: 512 + wallChecker: {fileID: 6530647677844077835} firePoint: {fileID: 3204799031628172313} attackCollider: {fileID: 5093782900058509363} - animator: {fileID: 0} rb: {fileID: 4986202531950816680} --- !u!1 &4475587780921916628 GameObject: diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs b/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs index bf5e4ac4..6496df3b 100644 --- a/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs +++ b/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs @@ -7,25 +7,29 @@ namespace TON public class CharacterBase : MonoBehaviour, IDamage { - [SerializeField] // - private PlayerData playerData; - public float currentHP; - public float maxHP; - public float currentSP; - public float maxSP; + [SerializeField] private PlayerData playerData; + [SerializeField] private float currentHP; + [SerializeField] private float currentSP; + private float maxHP; + private float maxSP; + + [SerializeField] private float speed; + [SerializeField] private float jumpForce = 5f; // 점프 힘 + [SerializeField] private float airControl; // 점프 힘 + + [SerializeField] private Transform groundCheck; // GroundCheck 위치 설정 + [SerializeField] private float groundCheckRadius = 0.2f; + [SerializeField] private LayerMask groundLayer; + [SerializeField] private WallChecker wallChecker; + - public float speed; - public float jumpForce = 5f; // 점프 힘 private bool isGrounded = true; // 플레이어가 바닥에 있는지 여부를 판단 private float lastDirection = 1f; // 기본적으로 오른쪽(1) 바라보는 상태 - + private VariableJoystick joystick; + private Animator animator; public Transform firePoint; // 스킬 발사 위치 public CollisionDetector attackCollider; // 기본 공격 감지를 위한 자식 오브젝트 - - public Animator animator; - - private VariableJoystick joystick; public Rigidbody2D rb; // ingame UI의 캐릭터 stat 적용을 위한 이벤트 @@ -73,8 +77,25 @@ namespace TON PlayerDataManager.Singleton.UpdatePlayerData(); } + // 게임이 실행 중이지 않을 때도 항상 기즈모를 보여줍니다 + private void OnDrawGizmos() + { + if (groundCheck == null) return; + + // 기본 색상을 흰색으로 설정 + Gizmos.color = Color.red; + // OverlapCircle의 범위를 와이어프레임 원으로 표시 + Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius); + } + + private bool CheckIsGrounded() + { + return Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer); + } + public void FixedUpdate() { + isGrounded = CheckIsGrounded(); // 키보드 입력과 조이스틱 입력 통합 float horizontalInput = Input.GetAxis("Horizontal"); @@ -86,31 +107,45 @@ namespace TON // 걷는 애니메이션 적용 animator.SetBool("IsMoving", Mathf.Abs(horizontalInput) > 0f); - // 기본 이동 속도 계산 - float newVelocityX = horizontalInput * speed; + // 공중/지상에 따른 이동 속도 계산 - // 경사로 감지 - bool isOnSlope = false; - Vector2 rayOrigin = rb.position; - RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.down, 1.1f); - - if (hit.collider != null && hit.collider.CompareTag("Ground")) // Ground 태그 확인 + Debug.Log("wallChecker.IsWallTouching::: " + wallChecker.IsWallTouching); + // 측면 충돌 체크 + if (!isGrounded && wallChecker.IsWallTouching) { - float slopeAngle = Vector2.Angle(hit.normal, Vector2.up); - if (slopeAngle > 0 && slopeAngle <= 45f) + // 벽을 밀고 있을 때는 수평 이동 제한 + rb.velocity = new Vector2(0, rb.velocity.y); + } + else + { + // 기본 이동 속도 계산 + float newVelocityX = horizontalInput * (isGrounded ? speed : speed * airControl); + + // 경사로 감지 + bool isOnSlope = false; + Vector2 rayOrigin = rb.position; + RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.down, 1.1f); + + if (!isGrounded) // Ground 충돌 확인 { - isOnSlope = true; - // 경사면 방향 벡터 계산 - Vector2 slopeDirection = new Vector2(hit.normal.y, -hit.normal.x); - rb.velocity = slopeDirection * (newVelocityX / Mathf.Cos(slopeAngle * Mathf.Deg2Rad)); + float slopeAngle = Vector2.Angle(hit.normal, Vector2.up); + if (slopeAngle > 0 && slopeAngle <= 45f) + { + isOnSlope = true; + // 경사면 방향 벡터 계산 + Vector2 slopeDirection = new Vector2(hit.normal.y, -hit.normal.x); + rb.velocity = slopeDirection * (newVelocityX / Mathf.Cos(slopeAngle * Mathf.Deg2Rad)); + } } + + // 경사가 아닐 경우 일반 이동 적용 + if (!isOnSlope) + { + rb.velocity = new Vector2(newVelocityX, rb.velocity.y); + } + } - // 경사가 아닐 경우 일반 이동 적용 - if (!isOnSlope) - { - rb.velocity = new Vector2(newVelocityX, rb.velocity.y); - } // 방향 전환 if (horizontalInput != 0) @@ -141,19 +176,6 @@ namespace TON { // 점프: 기존 X축 속도 유지, Y축 속도를 점프 힘으로 설정 rb.velocity = new Vector2(rb.velocity.x, jumpForce); - - // 점프 상태로 설정 - isGrounded = false; - } - } - - // 바닥 충돌 감지 (2D Physics) - private void OnCollisionEnter2D(Collision2D collision) - { - // Ground 태그가 붙은 오브젝트와 충돌 시 바닥 상태로 전환 - if (collision.gameObject.CompareTag("Ground")) - { - isGrounded = true; } } diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs b/Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs new file mode 100644 index 00000000..734d4f9a --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + public class WallChecker : MonoBehaviour + { + public bool IsWallTouching { get; private set; } + + private void OnTriggerStay2D(Collider2D other) + { + IsWallTouching = other.gameObject.layer == LayerMask.NameToLayer("Ground"); + } + + private void OnTriggerExit2D(Collider2D other) + { + if (other.gameObject.layer == LayerMask.NameToLayer("Ground")) + { + IsWallTouching = false; + } + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs.meta new file mode 100644 index 00000000..15421ffa --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/WallChecker.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 75a6dd00ee9c3d7428cae5700b2cc666 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: