Desperate for help here as this project killing crash has been plaguing me for months and I can only find a handful of cases of others experiencing it, and none know why it happens, or how to avoid it.
I have a rig of Rigidbodies interconnected by ConfigurableJoints utilising joint drives to pose the rig. It works exactly as intended, up until a seemingly random point usually about 1 minute into testing, at which point every Rigidbody in the rig prints this error to console:
"Skipped updating the transform of this Rigidbody because its components are infinite. Could you have applied infinite forces, acceleration or set huge velocity?"
Looking at the Rigidbodies in the inspector, they all have NaN values for velocity, angularVelocity and worldCenterOfMass. If I ignore the error and allow the application to continue playing, it crashes the entire Unity editor.
I’m assuming this is to do with the physics engine trying to resolve the joints, but it seems to happen whatever setting I tweak to try and avoid an infinite force. I’ve set low maximum force limits for all of my joint drives and I’ve even tried making all the joint limit springs elastic.
If no one knows how to avoid this happening, does anyone at least know of a way I can catch this as it happens and prevent the crash, and potentially reset the NaN values of the Rigidbodies?
I’m sorry, I don’t have a definitive answer for you. You don’t say what type of joint or show the code that you are using to move the joints (I know you say you are using drives). I think first you need to identify more detail about the problem.
It sounds like you have a test strategy to replicate the problem, so how about moving half the joints to fixed and repeating until you can identify one joint that will definitely cause the problem, then create a two body, one joint replicator with the simplest code possible. I know this sounds a lot of work, but it is likely to give the clearest insight into the problem.
Man… this is really weird i dont know how to help you, but if i found out HOW to i will let you know
(I think i’ve already faced this, but im not really sure)
Basically the error message is pretty accurate. You are likely adding some force to a rigidbody using some infinitely large or small value.
In my case… I was projecting a raycast from the center position of my bullet along its transform.forward to find the exact position where it was hitting the target.
In some cases, that raycast would miss the target and generate some infinite looking values. like these:
Using those values to apply forces to the rigidbodies caused the error. Here’s a snippet of where my problem was and the if/else statement fixed my problem.
.
.
.
Ray bulletRay = new Ray(transform.position, transform.forward);
RaycastHit hit = new RaycastHit();
col.Raycast(bulletRay, out hit, 100f);
print("hit.point.x: " + hit.point.x);
print("hit.point.y: " + hit.point.y);
print("hit.point.z: " + hit.point.z);
if (Mathf.Abs(hit.point.x) < 0.01f || Mathf.Abs(hit.point.y) < 0.01f || Mathf.Abs(hit.point.x) < 0.01f)
{
print("bulletRay Missed!");
target.TakeDamage(transform.position, transform.forward.normalized, gun.power, gun.damage);
}
else
{
target.TakeDamage(hit.point, transform.forward.normalized, gun.power, gun.damage);
}
Hi
I just encountered the same problem with the message “Skipped updating the transform of this Rigidbody because its components are infinite. Could you have applied infinite forces, acceleration or set huge velocity?”
Seems that I spawned a object halfway in the Terrain , so it was basically stuck in the Terrain and then I tried to accelerate it .
If anybody is running into this in the future, I don’t know if it was actually the cause of the problem but for me freeing up a bunch of my disk space on my computer seemed to solve it… I don’t know what else it could have been.