- Home /
Getting a configurable joint to point at another object
Hi all,
I've been working on a project with joints, and I've hit an issue with configurable joints that I can't wrap my head around. Say I have two objects:
Object A
Has a configurable joint
Rotation controlled by physics
Should always "look at" object B (unless prevented by other colliders)
Object B
The "target"
Can arbitrarily move around the scene
Basically I'd like Object A to be a physics-controlled object that always rotates to "look at" Object B.
I've been attempting this by setting the TargetRotation property of Object A to a Quaternion that looks at Object B. This causes Object A to rotate as Object B moves around the screen, but its rotation is not correct. Object A's rotation does not seem to follow or point at Object B in any useful way.
Here are the non-default properties of my joint:
X/Y/Z Motion: Locked
Angular X/Y/Z Motion: Free
Target Rotation: Set by a script
Rotation Drive Mode: Slerp
Slerp Drive: Position only (other values set to 1)
I guess I don't fully understand how the TargetRotation property works. I'm at a loss on how to fix this.
Thanks for reading.
Answer by VixOrien · Feb 16, 2012 at 02:26 AM
I figured it out!
Originally I was getting a vector pointing towards the Target from the joint and using Quaternion.LookRotation(). I needed to also invert the Quaternion (using Quaternion.Inverse) before setting it as the joint's TargetRotation.
It works great now.
Your answer
![](https://koobas.hobune.stream/wayback/20220613064118im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Violent shaking when using position drive in Configurable Joints 1 Answer
How can I make a configurable joint behave like a spring joint? 0 Answers
Joint system scale problems 2 Answers
Configurable Joint attaches at different points 0 Answers
Configure configurableJoint to act as the disctontinued driveJoint 0 Answers