Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Configurable joints in-depth documentation / tutorial / for dummies

Discussion in 'Physics' started by Miffeltoffel, Mar 1, 2016.

  1. Miffeltoffel

    Miffeltoffel

    Joined:
    Feb 9, 2015
    Posts:
    1
    So, I've been wanting to use the configurable joints for a vehicle suspension model, but the documentation didn't really answer the questions I had.

    While https://www.3dbuzz.com/training/view/unity-fundamentals/physics/13-configurable-joint
    answered some and was a great platform to start from, it still required a bit of fiddling before I was able to use them with satisfactory results, plotting down what I learned as I went.

    So, having had great use of this forum and all the answers here I thought I'd give back and share what I've found. If someone spots any error in my logic or has anything to add, please feel free to tell me, I definitely do not consider myself above error. :) So, here's what I found:

    Naming convention:

    Spring – The actual spring script
    Spring object – The object that contains the spring script
    Attached object – The other object that the spring is connected to

    AFAIK the springs are modelled using Hookes law, F = -kx -dv, where F is the resulting force, k is the spring stiffness, x is displacement, d is dampening coefficient and v is the velocity. Both displacement and velocity is that of the spring object relative the attached object.

    Axis/Secondary axis – Defines the primary/secondary axis of the spring coordinate system. If we set this to [0,1,0] for example, the spring main axis is in the spring objects Y-direction. This affects most settings. For example, the X motion setting then applies to the spring objects Y-direction.

    Configured in world space – Everything should be defined in world space instead.

    Swap bodies – This makes the joint behave as if the script was added to the attached object rather than the spring object.

    Break Force/Torque – If the Force/Torque specified here is exceeded, the configurable joint is removed from the object.

    Enable collision – Should the bodies in each end of the spring be able to collide?

    Enable preprocessing – This reduces the accuracy of the joint simulation but is very useful when some degrees of freedom are removed (some motions are set to 'Locked'), because PhysX can then ignore some calculations.

    Anchor – This defines where the spring is attached. Defined in the spring object coordinate system.

    Connected anchor – Where on the connected body the spring is connected. This is defined in the attached objects coordinate system, as opposed to the anchor.

    X/Y/Z Motion - Defines how the spring should behave linearly in the spring coordinate system.
    Free – Can move every which way
    Limited – Obeys the restrictions under ”Linear limit”
    Locked – Cannot move in the specified direction

    Angular X/Y/Z motion – Defines how the spring can rotate around the specified spring axes.
    Free – Can rotate every which way
    Limited – Obeys the restrictions under ”Angular limit” - note that this is divide into X and YZ. X is the primary axis, hence it will have more options.
    Locked – Cannot rotate about the specified axis.

    Linear Limit Spring – Define the spring end points behaviour.
    Defines end-position behaviour. If Spring/Damper = 0 the spring is forcably stopped in the end position (sort of when you hit the bottom of the dampers on your car when hitting a speed bump at high velocities, there is a hard shock).
    Spring (-kx): Equivalent to spring stiffness that decides how much it should oscillate around the end point
    Damper (-dv): Equivalent to damping coefficient that decides how much oscillation around end point is damped.

    Linear Limit – Define the spring end points.
    Limit: Defines how many Units the spring can be stretched/compressed.
    Bounciness: Equivalent to energy conservation at the end points.
    0 = all energy dissipated when end position is reached (like a lead ball dropped),
    1 = all energy conserved when end position is reached (like a bouncing ball)
    Contact distance: How far away from the current position the joint looks to see if we are close to the limit. If this is =0 there is no prediction which is faster but may become jittery since we have no prediction.

    Angular X limit spring – Defines how the spring should behave around the end-position of the allowed rotation.
    Spring (-kx): Equivalent to spring stiffness that decides how much it should oscillate around the end point
    Damper (-dv): Equivalent to damping coefficient that decides how much oscillation around end point is damped.

    Low/High angular X & Y/Z limit – Defines the lower/upper boundary of the rotation. Note that X is independent and YZ have to be specified together.
    Limit: Defines how many degrees (NOT RADIANS) the spring can be stretched/compressed radially.
    Bounciness: Equivalent to energy conservation at the end points. 0 = all energy dissipated when end position is reached (like hitting a brick wall), 1 = all energy conserved when end position is reached (like hitting a rubber surface)
    Contact distance: How far away from the current position the joint looks to see if we are close to the limit. If this is =0 there is no prediction which is faster but may become jittery since we have no prediction.

    Target position – Set the position in spring space where the end point of the joint should aim to be (the rest position of the spring). Creates a distance in the direction of the primary axis from the anchor to the connected anchor. Example: Setting this to [1,0,0] will move the spring object to [-1,0,0] relative the connected anchor (in the spring coordinate system).

    Target velocity – Set the contant velocity the spring should try to achieve in spring space.

    X/Y/Z Drive – Defines what method we use to control the spring. All defined in spring space.
    Position: Uses Position Spring (Spring stiffness) – equivalent to the kx-term
    Velocity: Uses Position Damper (Damping coefficient) – equivalent to dv-term
    Position and velocity: Uses both terms, complete Hooke's law.

    X/Y/Z Drive - Defines behaviour around the mid-position of the spring.

    Projection mode – This is a ”Last resort” kind of solution if the spring violates the limits too badly. This has nothing to do with physics and is used only to make sure that things do not explode and go haywire.
    Position and Rotation: If the joint goes above/below the allowed limits it will automatically snap back to the limit.
    Projection distance: How much above/below the linear limit does it have to be before we snap back?
    Projection Angle: How many degrees above/below the angular limit does it have to be before we snap back?


    Hope this helps someone with this very powerful (but slightly underdocumented) feature!
     
    Threeyes, Pecek, Magic73 and 6 others like this.
  2. emugod

    emugod

    Joined:
    Nov 22, 2013
    Posts:
    6
    I'm not positive but it seems like the Axis settings are used to define different axes, relative to the default of the objects local axes. If you leave them (0,0,0) you will have everything working in the objects local space.
     
  3. emugod

    emugod

    Joined:
    Nov 22, 2013
    Posts:
    6
    Just discovered; The object is not treated as a static collider once at its limit. If you're pushing against it with a kinematic rigidbody, it will ignore the limit and keep moving, rather than having your kinematic pass into and through it.
     
  4. domilab

    domilab

    Joined:
    Mar 23, 2013
    Posts:
    13
    Thank you so much for this post. I've also noticed that the documentation is poor at best and the video was helpful but not enough. Maybe you could provide some insight where I'm still confused.

    Is it possible to use this joint to pull things together? I'm guessing this would involve the linear limit/spring and bounciness. Say I had an anchor point 100 units away. I want the object to be pulled to within 4 units and stop. Is this possible with this joint? I tried something similar with the spring joint but my results are never what I expect.

    Edit: Could the drive be used to maintain the speed on how fast it's pulled back? If I wanted a constantly velocity, is that possible?
     
    Last edited: Aug 30, 2016
  5. Static-Dynamo

    Static-Dynamo

    Joined:
    Aug 18, 2013
    Posts:
    11
    The documentation on the configurable joint is really bad and is making things much more difficult than they have to be. I've been trying to figure out how to set projection mode via script and have had no luck. Anyone know how to do this? The documentation doesn't give any explanation on if it's even possible. I've had success setting everything else I need for my behavior via script, except for this one part.
     
  6. electric_jesus

    electric_jesus

    Joined:
    Mar 8, 2015
    Posts:
    30
    It seems like Target Angular Velocity and Target Rotation of a ConfigurableJoint are measured in the opposite directions. At the same time Target Velocity and Target Position are both measured in the same direction. It just blows my mind.
    Tested with Unity 5.3.8 and Unity 5.4.3.
     
    Last edited: Jan 20, 2017
  7. bsmall

    bsmall

    Joined:
    Sep 24, 2015
    Posts:
    51
    Yes, same for me, i can't understand why its not a priority in unity team to improve and (better)explain these basic tools.
     
    electric_jesus likes this.
  8. thieum

    thieum

    Joined:
    Apr 8, 2011
    Posts:
    46
  9. adhochero

    adhochero

    Joined:
    Feb 2, 2017
    Posts:
    27
    I have a question about the option "Mode" for the x,y,z Drives, mine dosent have Mode
     
  10. Sword111

    Sword111

    Joined:
    Feb 28, 2016
    Posts:
    8
    Hi maybe someone can help me, with a configerable joint problem that ivhttps://youtu.be/PJ50zboeds8e been battling with for weeks?Works ok with a hinge joint but i need the full range or colliding movement ! Would anyone know how to get the point to sping back into line? Tried evey sort of tweek .. something simple im missing but dont know what ! Thanks Hugo
     
    Last edited: Mar 27, 2017