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:
- Has a configurable joint
- Rotation controlled by physics
- Should always “look at” object B (unless prevented by other colliders)
- 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.