오버플로우로 유니티 먹통되는 코드 수정

This commit is contained in:
Mingu Kim
2025-08-15 20:53:23 +09:00
parent 89a2bfa424
commit f2a72a8aa2
2 changed files with 19 additions and 18 deletions

View File

@@ -31,6 +31,15 @@ public class PlayerMove : MonoBehaviour
RigidBody = GetComponent<Rigidbody2D>();
SpriteRenderer = GetComponent<SpriteRenderer>();
Animator = GetComponent<Animator>();
// Null 체크 추가
if (RigidBody == null || SpriteRenderer == null || Animator == null)
{
Debug.LogError("PlayerMove script requires Rigidbody2D, SpriteRenderer, and Animator components on the same GameObject.");
// 게임 오브젝트 비활성화 또는 스크립트 비활성화
enabled = false;
return;
}
// 2. Animator가 초기화된 후에 해시 값 할당
_isJumping = Animator.StringToHash("isJumping");
@@ -68,4 +77,4 @@ public class PlayerMove : MonoBehaviour
{
// OffDamaged 로직은 DamagedState의 Exit()로 이동
}
}
}