Search Unity

Configurable Joint: Setting target position

Discussion in 'Physics' started by Qleenie, Sep 29, 2019.

  1. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    867
    Hi,

    I somehow understood that target rotation is dependent on the start rotation and found an extension script for configurable joint, which works quite nicely.
    But I somehow cannot figure out how to use target position in the same way. What i want to achieve is quite simple: I want to move a rigidbody with joint to a specific position. But I cannot figure out how to calculate the values to set for target position based on world location of a target object.
    Best I came up with was: - transformToMove.InverseTransformPoint(targetTransform.position).
    This somehow works, but not exactly, there seems to be some factor missing. I could not find any documentation about how to use / to interpret the local position.
    Second issue is that in this case I probably need to set the motion limits to free or unlimited, which leads to my rigidbody detaching from the relative position to it's parent.
    Can anyone help ? I can achieve something similar with force of course, but somehow (at least on rotation) the configurable joint drives seem to behave more stable.

    Thanks!