- Home /
Transform joint.anchor to world coordinates
Hi,
I'm currently trying to create a joint anchor where raycast hit.point is touching. The problem is, hit.point is in world coordinates and joint.anchor is in local coordinates. How can I correct that ? I'm pretty sure I have to use transform.TransformPoint but I don't know how.
Here's my code :
ConfigurableJoint joint = longCube.AddComponent<ConfigurableJoint> ();
joint.anchor = hit.point;
joint.axis = hit.normal;
Thanks for reading.
Thanks again hexagonius :) TransformPoint didn't work but InverseTransformPoint did. Thanks for your help.
Answer by hexagonius · Mar 25, 2015 at 06:02 PM
transform.InverseTransformPoint(Vector3 position) converts position to the transforms local Space. In your case, position is the hit.point and transform should be the transform of longCube.
joint.anchor = longCube.transform.InverseTransformPoint(hit.point);
Your answer
![](https://koobas.hobune.stream/wayback/20220613191134im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Joint system scale problems 2 Answers
Is spring joint possible with configurable joint? 0 Answers
How to make rigidbody move with another rigidbody respecting physics? 1 Answer
How can I make a configurable joint behave like a spring joint? 0 Answers
How to rotate object about 2 axes (vertical y and depth z) using configurable joint. 0 Answers