Players head clamp & weight comes undone occasionally on jump

Silver100

Member
Hi,

I have noticed the players look at head weight and clamp, when set to 1 to lock in place, on occasions comes undone on jump and head will look at the camera. Is there a way to prevent this from happening?
 
Last edited:
It's really hard to say based on that description but maybe you have a state that is changing the value?
 
Thanks,

I just had a check through (and tested on a recent character below) checked through all states and defaults states but no head weight or clamps mentioned or altered. It happens under the condition, jumping + rotating in air with left stick, + firing at the same time. Also with jump force value set to 1 or more.
I noticed that unchecking face target on the rifle animator object makes the weapon rotate toward the cross hair almost reversing around in the players hand as the weapon rotates faster than the player?

I have checked as below with a more recent created character again the players look at head weight and clamp, when set to 1 to lock in place, on occasions comes undone on jump and head will look at, and face back looking at the camera.
Also unchecking face target on the rifle animator object makes the weapon follow faster than the player moves too.

 
Last edited:
Are you able to reproduce the same thing within the demo scene of a fresh project?
 
Thanks, Yes I am able to re-create in the demo scene Atlas head rotating and facing the camera with head weight and look at clamp applied to full at 1, again testing with jumping + rotating in air with left stick, + firing at the same time. Setting jump force to 1 or higher (rather than default 0.2) . It takes a while to produce but will eventually happen. It's basically like a random look and face the camera, I think its becomes more apparent when the player is able to jump higher giving the probability of this happening a higher chance. Also the fact I am creating a game where there is lots of jumping rotating and shooting.

I have recorded the demo scene version repeating the issue below;


Just a guess but I think the Unity Input IK script clamp options work on animations playing as opposed to restraining each bone. During state transitions has potential for clamp briefly to not be effective but really just a guess here.


Pic1.png
 
Last edited:
Thanks these are the exact steps;

In the demo scene;

Locate Atlas change change the jump force value set to 1.5 under abilities - jump on the character
Drag in Atlas to hierarchy to access the character IK script
Apply 1 to both look at body weight and head weight
Go into shootables & pick up say shotgun then;

Keep rotating mainly forward then back with jumping with left stick and with fire held down or repeated
Its takes a while but you can see a wobble on the head
Eventually Atlas will look back at the camera this takes a minute of repeating above
This is where I need to lock in place the head.

Running and jumping combined with the above seems to make this happen more too.

Also;
I have gone through Opsive documents but cant figure which script handles where the players head is able to follow look direction. I thought it may be the camera so tested unclamped and players head still follows look direction without the head selected on camera?
 
Last edited:
I am not able to reproduce it. When the character stops firing they can rotate but in this situation its the character transform rotating and not just IK. If you enable the debug ray on the CharacterIK component is it pointing in the correct direction?

I have gone through Opsive documents but cant figure which script handles where the players head is able to follow look direction. I thought it may be the camera so tested unclamped and players head still follows look direction without the head selected on camera?
That's the CharacterIK component. It talks to the LookSource to determine the look direction.
 
No prob thankyou for checking. The demo version I tested is version update 3.0.18V in a fresh new project with the issue occurring. The issue is more easier to produce in a new character set up at least for me. Narrows it down more compatibility issue my end hardware, software update or a more constant setting I have. I am using a Lenovo legion5 RTX 3070, Unity version minimum required to use Opsive with Unity version 2021.3.21f.
If I can will try and get tested on other devices as this is something I need to do.
With the debug; I have clicked on the bug icon and followed above, selected birds eye view in editor and then I can see a long green line that appears or vanishes when clicking debug ray check box and is pointing in the correct direction so that looks good.
Also realised in editor mode scene view I couldn't control the player and create those conditions and movements
So made changes so the player fires and jumps aims by itself still looks like all look source with weapons firing is aiming correctly so this aspect looks fine.

Pic.png
 
Last edited:
This is looking like it could be an Animator bug since the look direction is correct. One final check is to add:

Code:
Debug.DrawLine(m_Head.Position, m_LookAtPosition);

on line 821 of CharacterIK.cs. If the debug ray looks correct then it's a Unity bug and you could try reporting it to Unity. With that said, a quicker alternative would be to use FinalIK instead of Unity's IK component
 
Thanks,

On line 821 I have added in
Code:
Debug.DrawLine(m_Head.localPosition, m_LookAtPosition); // for some reason needed to add local to work. Its facing the correct direction.
I have very little experience in debugging though.

I will check replacing Unity's IK component with Final IK too. Where is Unity's IK located?

In terms of just getting the head locked in place to prevent the character looking back;

I have found a solution working only for characters with '1 neck bone only' (like Atlas).

I added a bone clamp script I found on line to drag and clamp bones. This clamps each bones directly so far I can only successfully clamp 1 at a time.
I then set a max and minimum value on the neck X axis so its 15 degrees locked forward/ down matching my original pose, and then Y ,Z locked to '0'.
If I combined with Character IK Clamp to head will totally lock head in place but both methods (script I located & Character IK) needed to be used. The head will never rotate now or lean of look up/down I have tested. Some of my models have up to 3 separate neck bones and I can't seem to find a solution for those. I have attempted to constrain all 3 neck bones, but I can only clamp 1 bone.

Just an idea/suggestion;

Really would appreciate more methods for totally clamping bones/multiple bones and even more options for head look source control. It would be great to add a drag in bone constraint feature in addition Character IK/ animator clamp, to give additional bone constraint when needed so there is additional extra layer of flexibility for getting results when running into issues etc.
 
Last edited:
Oops, you should do m_Head.position instead of Position. Regardless, if it's facing in the correct direction then it's a bug with the Animator. I'm glad that you found a workaround at least for one bone necks.

Really would appreciate more methods for totally clamping bones/multiple bones and even more options for head look source control. It would be great to add a drag in bone constraint feature in addition Character IK/ animator clamp, to give additional bone constraint when needed so there is additional extra layer of flexibility for getting results when running into issues etc.
That sounds like it could end up being an asset on its own :) For IK we completely rely only the internal implementation or another asset such as FinalIK.
 
Yes it seems quite involving but good to have more of an understanding of what is happening and save time by exploring options :) I'm going to keep the character heads locked in place for now and any more models to have 1 neck bone. I will eventually try different methods like FinalIK. Thanks for your help on this, the main thing is it's looking much better.
Code:
m_Head.position instead of Position
That worked still facing the correct direction
 
Last edited:
Top