So, I’ve created a simple rope using HingeJoints, so I can have the rope react to physics in the environment. It is made of 9 connected Capsules, each of which has a HingeJoint and Rigidbody attached. I have also created a pause system, that allows the entire game to pause by setting the Time.timeScale to 0 (the error does not occur when setting it to higher values than 0). My issue is that, after pausing and unpausing the game, I get this error:
transform.position assign attempt for 'Capsule' is not valid. Input position is { NaN, NaN, NaN }.
This error appears every frame, 9 times (one for each capsule in the rope), and the debug messages instantly slow the game down. Looking up this problem, I found that joints in general are apparently difficult to “stop” and “start” again. I read that the correct thing to do was call rigidbody.Sleep()
, to ensure the physics is halted correctly. I built a system using event listeners, so I could attach a script to call this method, that would be fired by my pause script, but this achieved nothing, and the effect still occurred. Could anyone help me work out exactly what is wrong here?
EDIT: On further inspection, it seems the issue is not with HingeJoints. The rope has a flag attached to it, which is simply a plane of InteractiveCloth. If I disable the cloth, everything works perfectly as expected.