Player가 자식 오브젝트까지 오른쪽(스프라이트를 강제로 좌우 반전 시켰을 때 콜라이더가 반대로 생성되어 수정)을 바라볼 수 있도록 코드 수정

This commit is contained in:
Mingu Kim
2025-08-22 21:23:07 +09:00
parent cf41a64529
commit 8790e3982a
3 changed files with 21 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ public class PlayerMove : MonoBehaviour
RigidBody = GetComponent<Rigidbody2D>();
SpriteRenderer = GetComponent<SpriteRenderer>();
Animator = GetComponent<Animator>();
// Null 체크 추가
if (RigidBody == null || SpriteRenderer == null || Animator == null)
{
@@ -36,12 +36,22 @@ public class PlayerMove : MonoBehaviour
return;
}
// 캐릭터의 기본 방향을 오른쪽으로 설정
Vector3 initialScale = transform.localScale;
initialScale.x = -1f;
transform.localScale = initialScale;
_stateMachine = new StateMachine(State.IDLE, this);
// 공격 콜라이더 참조
attackCollider = GetComponentInChildren<Collider2D>();
}
void Start()
{
}
private void Update()
{
_stateMachine.Update();