Multi-Aim Constraint Rotation Limits

Hi,

Is there a way or will there be a way to set rotation limits per-axis with a min/max angle for using a Multi-Aim Constraint or other constraints?

I'd like to avoid this:

5825371--617428--rotation_limits_break.gif

...Maybe its a feature I should keep maybe not hahah

But having my player bend too far up, down, left, and right not only looks weird but can cause discontinuities in the rotation as seen above and then all sorts of bad things can happen.

I am able to use FinalIK angle limits to set a single axis rotation limit per bone while using Animation Rigging but this functionality is fairly limiting as I need multiple axis limits with different min/max values per bone.

The only other solution I can think of would be to lock my target within some bounds in front of the character but it would be far more pleasurable to just set some rotation limits and call it a day.

Any ideas?

Thank you for your time.

2 Likes

I had same problem and took a look to code. I found these lines for twist correction. And pointed where limit can be applied. It's in TwistCorrectionJob.cs

for (int i = 0; i < twistTransforms.Length; ++i)
                {
                    ReadWriteTransformHandle twistTransform = twistTransforms[i];

                    float twistWeight = Mathf.Clamp(weightBuffer[i], -1f, 1f);
                    Quaternion rot = Quaternion.Lerp(Quaternion.identity, Mathf.Sign(twistWeight) < 0f ? invTwistRot : twistRot, Mathf.Abs(twistWeight));
                   //Here rotation limit function can be implemented.
                    twistTransform.SetLocalRotation(stream, Quaternion.Lerp(twistBindRotations[i], rot, w));

                    // Required to update handles with binding info.
                    twistTransforms[i] = twistTransform;
                }

For you MultiAimConstraintJob before line 110 you can limit it which is this line. So you may limit it after lerp or before lerp. It's up to you to handle that. But really it should be in stock code. Because there are lots of interfaces going on.

driven.SetLocalRotation(stream, Quaternion.Lerp(drivenLRot, newRot, w));
1 Like

I just decompiled some data from dll and created similar interface to it. So now trying to limit it.

Thanks for the lead Segant!

I found a way to use the FinalIK rotation angle limits more cleverly for my use-case that has solved the problem for now. My time is pretty limited so I'll keep working on other tasks and maybe when I revisit another quality-pass there might be more functionality exposed by the rigging package.

I have done it via copying 3 cs file and changing them as I wanted.

1 Like

Files are mainscript, editor script of main script and job script
5838259--619504--upload_2020-5-12_20-16-19.jpg