- Home /
Get a NaN error when unpausing a game
When i pause the game using this script
http://paste.thedigitalboard.com/index.php/view/17729211
Now when i pause my ai characters stop moving
But when i unpause, the characters fall through the ground and give a NaN error
Heres the script that causes the error
http://paste.thedigitalboard.com/index.php/view/44016802
the error is with this line
character.SimpleMove(transform.TransformDirection(computer.deltaPosition)/Time.deltaTime); and the error is
transform.positionWithLocalOffset assign attempt for 'MuhZomb(Clone)' is not valid. Input positionWithLocalOffset is { NaN, -2.799626, NaN }. UnityEngine.CharacterController:SimpleMove(Vector3)
Any help would be appreciated
It actually happens when i pause, the characters just dis-appear :/ **
Answer by Landern · Dec 05, 2012 at 09:18 PM
hmm... div/0...maybe, try instead of dividing:
character.SimpleMove(transform.TransformDirection(computer.deltaPosition)/Time.deltaTime);
try
character.SimpleMove(transform.TransformDirection(computer.deltaPosition) * Time.deltaTime);
It is defo to do with the Time.deltaTime dividing by 0
@Landern I was pausing the game with Time.timeScale=0;
and with this insight about the 0, I changed it to a very small number and the NaN error I had is gone.
Your answer
Follow this Question
Related Questions
Should you use CharacterController.Move or SimpleMove for enemies? 1 Answer
Simple networked AI works if only one, but freaks out client-side if more than one 1 Answer
Enemy following Player on uneven surface 1 Answer
I'm trying to make AI that walks (and faces) towards a waypoint 1 Answer
AI movement bug ("teleporting" after certain Platforms) 0 Answers