Search Unity

Question build a "pre-loaded" joint

Discussion in 'Physics' started by meiru, May 11, 2023.

  1. meiru

    meiru

    Joined:
    Aug 11, 2017
    Posts:
    19
    is there a good example about how to build "pre-loaded" joints? (or wouldn't it be a good utility function in case it doesn't exist?)

    assume the following:

    you have a scene with 2 objects... you connect them via a ConfigurableJoint (let's say the relative rotation between those objects is zero, the distance 1 and the anchor and connectedanchor of the joint is pointing right in the middle of those objects

    then you apply a force (gravity, something else... doesn't matter)... in the end your joint is no longer in its origin position but slightly moved in a direction and it's also slightly rotated (just as an assumption)

    now you save the position of those objects and reload them and you want to rebuild this joint

    how would you do that?...

    my idea was to build the joint, calculate the anchors... but how? and you would also have to set a target rotation (I guess) because the joint should rotate the objects back into its original position, when the force is no longer applied...

    ... what's the easiest way to code this? (given that none of the anchors is zero!)
     
    Last edited: May 12, 2023