코드로 두 오브젝트의 일정 거리를 구해서 인접했을 경우 NavMesh의 isStopped 함수로 추적을 멈추게 할 수 있습니다.
Rigidbody의 Constraints - Freeze Position의 X, Z 값을 고정시키면 외부에 의해 밀려나지 않습니다.
코드 혹은 컴포넌트 설정을 통해 해결할 수 있습니다.
public class Player : MonoBehaviour
{
Rigidbody rigid;
void Awake()
{
rigid = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
FreezeRotation();
}
void FreezeRotation()
{
rigid.freezeRotation = true;
}
}
Constraints - Freeze Rotation의 X, Y, Z값을 모두 체크하면 됩니다.
Rigidbody rigid;
void Start()
{
rigid = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
FreezeVelocity();
}
void FreezeVelocity()
{
rigid.velocity = Vector3.zero;
rigid.angularVelocity = Vector3.zero;
}