Search Unity

Bug Joint Crash- "Skipped updating the transform of this Rigidbody because its components are infinite."

Discussion in 'Physics' started by MUG806, Feb 21, 2021.

Thread Status:
Not open for further replies.
  1. MUG806

    MUG806

    Joined:
    Jul 20, 2014
    Posts:
    4
    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?
     
    CandraWi likes this.
  2. MUG806

    MUG806

    Joined:
    Jul 20, 2014
    Posts:
    4
    Giving this a bump as I'm no closer to figuring this out a week later.
     
  3. AlTheSlacker

    AlTheSlacker

    Joined:
    Jun 12, 2017
    Posts:
    326
    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.
     
  4. SuHomunculoRiko

    SuHomunculoRiko

    Joined:
    Feb 17, 2021
    Posts:
    4
    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)
     
  5. bernhardt12

    bernhardt12

    Joined:
    Dec 17, 2020
    Posts:
    4
    Hey, just solved this.

    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:

    hit.point.x: 2.977644E+08
    hit.point.y: 1.401298E-45

    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.

    .
    .
    .


    Code (CSharp):
    1. Ray bulletRay = new Ray(transform.position, transform.forward);
    2. RaycastHit hit = new RaycastHit();
    3. col.Raycast(bulletRay, out hit, 100f);
    4.  
    5. print("hit.point.x: " + hit.point.x);
    6. print("hit.point.y: " + hit.point.y);
    7. print("hit.point.z: " + hit.point.z);
    8.  
    9. if (Mathf.Abs(hit.point.x) < 0.01f || Mathf.Abs(hit.point.y) < 0.01f || Mathf.Abs(hit.point.x) < 0.01f)
    10. {
    11. print("bulletRay Missed!");
    12. target.TakeDamage(transform.position, transform.forward.normalized, gun.power, gun.damage);
    13. }
    14. else
    15. {
    16. target.TakeDamage(hit.point, transform.forward.normalized, gun.power, gun.damage);
    17. }
     
  6. Bob_work

    Bob_work

    Joined:
    May 5, 2020
    Posts:
    113
    I have the exact same problem as you!
    Do you resolve it ? I guess you did it, pleas tell me some clue about this, thanks!
     
    Last edited: May 21, 2022
  7. unity_spy01

    unity_spy01

    Joined:
    Aug 27, 2017
    Posts:
    1
    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 .
     
  8. DoctorSauce

    DoctorSauce

    Joined:
    Nov 4, 2012
    Posts:
    4
    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.
     
Thread Status:
Not open for further replies.