오버플로우로 유니티 먹통되는 코드 수정
This commit is contained in:
@@ -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()로 이동
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user