Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Fixed Joint 2D cannot stop Dangling (like a spring?)

Discussion in '2D' started by EnchantmentLevelV, May 19, 2024.

  1. EnchantmentLevelV

    EnchantmentLevelV

    Joined:
    May 19, 2024
    Posts:
    2
    I used fixed joint 2d to connect various parts of my spaceship together. whenever a part is hit, the whole ship will be pushed to the opposite direction. And ship components could be added or destroyed individually.

    However the fixed joint 2d doesn't fix the relative position and angles for 2 rigidbodies, it seems to work like spring, dangling around. in some situations, it will create a total mess. any idea what I'm doing wrong or how should I get around it? thanks in advance

    issue demonstrated in the following gif: I started the thruster on the right, pushing the thruster to the left, (expect to bring all the ship left) results in a mess
    fixedjoint2d.gif

    my code for adding fixed joint 2d
    upload_2024-5-19_10-56-2.png
     
  2. samana1407

    samana1407

    Joined:
    Aug 23, 2015
    Posts:
    293
    I am very confused by
    joint.frequency = 1_000_000
    . Setting it to 0 is sufficient for an unbreakable fixation.
     
  3. EnchantmentLevelV

    EnchantmentLevelV

    Joined:
    May 19, 2024
    Posts:
    2
    I was trying out different parameters, 0 or 1e6 doesn't make a noticeable difference to me
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,761
    Then likely you're using large mass-ratios, directly modifying positions via the Transform/Rigidbody, using huge forces, not increasing solver iterations (especially when using chains of joints) etc.

    Clearly the FixedJoint2D doesn't do that normally (explode) but it's not difficult to narrow down how you're causing it problems.

    Spin-up a project add "2 rigidbodies" and see it doesn't happen. Then start doing whatever you're doing above.