유니티에서 물리 오류가 나는 경우의 대부분은 FixedUpdate.



물리 오류가 나는 경우 대부분은 


물리 연산이 들어가는 캐릭터 이동을 FixedUpdate가 아니라 Update에서 처리한 경우.



FixedUpdate에서 처리하면서 Time.deltatimeTime.fixedDeltatime으로 고쳐써준다.


혹은 코루틴의 경우


null 이 아니라 new WaitForFixedUpdate()를 리턴해주자.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    protected override IEnumerator SprinterCoroutine()
    {
        while (true)
        {
            _Rigidbody.MovePosition(transform.position + transform.forward * Spd * Time.fixedDeltaTime);
            yield return new WaitForFixedUpdate(); // fixedUpdate를 기다린다.
        }
    }
 
    protected override IEnumerator SprinterCoroutine()
    {
        while (true)
        {
            transform.Translate(transform.forward * Spd * Time.deltaTime);
            yield return null// Update를 기다린다.
        }
    }



댓글

Designed by JB FACTORY