- Home /
Constraint not totally working after manually overriding a joint rotation
I'm trying to make a 3rd person camera system and I'm so close to having everything working correctly. The issue I'm having is with coordinating vertical camera orbit with vertical sternum rotation while aiming up/down.
In order to do this, as I'm orbiting my camera to look upwards and downwards, I'm manually forcing the "sternum" joint to rotate via code in the lateupdate(). The gun model has a parent constraint component with a source set on the hand, and another source set on an empty gameobject on the player's back. That way, I can have the weapon holstered, or drawn, or anything else I want (multiple parents), and also easily switch out other weapons.
The issue is that the gun rotates "horizontally" with the player, but doesn't tilt upwards/downwards Here's a picture of what I'm getting. The scene view is the right window. The transform gizmo by the hand is the "constraint" object that's parented to the hand joint that the gun is supposed to use as a source for it's Parent Constraint component:
I think what's happening is that the gun's Parent Constraint is happening before the Update() and LateUpdate(), making it act as though there's no override of the joint heirarchy below it, but I'm not sure. I guess this question all comes down to; "Do constraint components do their operations before the lateupdate/do they not update after the lateupdates are finished, and if so, why the hell not?". Many thanks to anyone who can help me figure this out.
I think constraints only work if you are using physics to move it.
I think you're thinking of something else. I'm using a "Parent Constraint Component" that's being added to the gun model. This way I can set up multiple constraint sources so that it can be constrained to the character's hand, or holster, or any number of things by adding those objects as "sources". https://docs.unity3d.com/Manual/class-ParentConstraint.html I should add that it works fine normally, but when I override the "vertical" rotation of something higher up in the source's hierarchy, the gun doesn't vertically rotate accordingly, yet it still rotates "horizontally"