Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity 5 joints freak the **** out

Discussion in 'Physics' started by Big_Friggin_Al, Oct 19, 2016.

  1. Big_Friggin_Al

    Big_Friggin_Al

    Joined:
    Jan 9, 2014
    Posts:
    22
    I have a rope made of simple cylinders, connected with configurable joints. They are not parented to each other. I want to restrict the motion of the rope to two dimensions, so I have all three motion settings locked and two of the angular motions settings locked, with the remaining angular motion setting as limited (and settings of limit 5, bounciness 1, contact distance 0).

    At the end of the rope I have a simple cube, also attached with a configurable joint using the same settings as the rope joints.

    The rope works beautifully at first, but then very quickly starts going totally crazy, with all of the component cylinders vibrating insanely all over the screen and bashing into everything else in the scene.

    I have tried every combination of settings I can think of, I've also tried character joints and hinge joints, all with the same result.

    What am I doing wrong here? What is the proper way to simulate a 3d rope that only operates in 2 dimensions?
     
  2. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,661
    Have you tried using a little drag so the joints slow down over time?
     
  3. Big_Friggin_Al

    Big_Friggin_Al

    Joined:
    Jan 9, 2014
    Posts:
    22
    Thank you for the suggestion but the problem was something else.

    For anyone else with this problem, make sure your anchors are set where they should be (i.e. where the pieces would physically join in real life), automatic connected anchor set to checked, and make sure you're only using one axis to orient your pieces when you build your rope (and if you're doing it in code, set the euler angles instead of using a quaternion).

    In my case, in addition to anchors being out of place, I was using either multiple rotations to set the pieces' headings (in the editor) or quaternions to set them in code. In both cases, having the X, Y and Z rotations all be set to something weird like 19.315, 32.1226, 75.194 degrees just to make it look like it was facing the right way meant that the joint's angular locks couldn't function properly once other rigidbodies started hitting my rope.

    I remade the rope making sure the pieces were either rotation 0, 0, 0, or in my case 0, 0, 90 so they matched with my gameplay plane, and then only used euler angles to orient the pieces in the direction I wanted the rope to go (so then the pieces would be like 0, 17.12, 0 or in my case 0, 17.12, 90, to make sure the rope went from its starting point towards its target). Then I made sure my angular locks were all locked except for the one which allowed the rope to swing on my gameplay plane, and everything is now working like a charm!
     
    DroidifyDevs likes this.