I am trying to call the same function as Activate
button of the Parent Constraint
component but it seems there’s no such method in the API:
Guess the code is hidden in the component’s editor script. Was trying to achieve the same result using SetTranslationOffset
and SetRotationOffset
which looked pretty straight forward but ended up with objects jump a bit when the function is called:
var positionDelta = parentConstraint.transform.position - source.position;
var rotationDelta = Quaternion.Inverse(source.rotation) * parentConstraint.transform.rotation;
parentConstraint.SetTranslationOffset(0, positionDelta);
parentConstraint.SetRotationOffset(0, rotationDelta.eulerAngles);
I don't know WHY it works, but it works! Thanks!
– Calashmad life saver omy goodness I spent the last couple days pulling my hair out for this
– Xylography