I am working on a game in Unity and I am currently getting this error when pulling up my menu.
Here is the script
private void OnAnimatorMove()
{
float delta = Time.deltaTime;
enemyManager.enemyRigidBody.drag = 0;
Vector3 deltaPosition = anim.deltaPosition;
deltaPosition.y = 0;
Vector3 velocity = deltaPosition / delta;
enemyManager.enemyRigidBody.velocity = velocity;
}
CodePudding user response:
Sounds like OnAnimatorMove
is also being called outside of PlayMode
where Time.deltaTime
most probably is simply 0
=> division by 0
=> generally not a good thing to do ;)
You could probably avoid that by checking
private void OnAnimatorMove()
{
if(! Application.isPlaying) return;
...
}
or maybe
if(Mathf.Approximately(Time.deltaTime, 0f)) return;
Also see this thread