Search Unity

[Q] Physics chain optimization

Discussion in 'Physics' started by Hawaiianspawn, Jan 1, 2017.

  1. Hawaiianspawn

    Hawaiianspawn

    Joined:
    Mar 26, 2016
    Posts:
    1
    Hello I have a physics chain about 7 hinge joints long.
    Example


    I've heard the suggestion of updating the timeStep for the project to something lower like 0.002[default is 0.02].

    What I have tried so far
    -Joint Chain in/out of hierarchy [Out works better]
    -Set Projects >Time timeStep = 0.0005 [Absolutely crazy]
    Which works well but destroys every other time based dependency
    -Springjoint spam [Does not work]

    The chain is 7 hinge joints

    I just want to know if there is any type of workaround available. I'm at a loss for a good solution other than writing my own script for it

    Thank you in advance for any help!
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    I've done a similar chain. Here's how I set it up

    The chain links are joined more or less at the edges, the top of one to the bottom of the next. I used HingeJoints and Distance Joints. The latter had a very small distance. This ensured that the chains didn't break apart too easily.

    I also had a DistanceJoint between the two objects that the chain held together. This had a distance that was the same as the length of the chain.

    I did change the Time Step, but only by 50 %.

    This chain holds up pretty well, it is still possible to break it apart if one goes really fast and it gets stuck on a corner. But, for the most parts it works as intended.