FinalIK: How to control the IKTarget?

GameDevDave

New member
The bridge script creates an IKTarget that latches itself onto the looksource location, I have no way to control/move the IKTarget now... All I want to do is change the positions of FinalIK targets in world space... Basically I still want to be able to enjoy FinalIK's simplicity without losing UCC's wonderfully sophisticated functionalities...
 
The FinalIK target is set so the character will look in the appropriate direction of the View Type. If you'd like to override the target yourself you can use the Look At ability: https://opsive.com/support/documentation/ultimate-character-controller/character/abilities/included-abilities/detect-object-ability-base/look-at.

The Look Ability uses the Detect Object Ability Base parent class to allow you to dynamically select which trigger to look at. If you don't want to use a trigger you could create a new ability similar to the Look At ability that just calls CharacterIKBase.SetLookAtPosition(true/false, position).
 
Last edited:
I did what you said and followed the documentation, nothing happened
1675475835921.png
1675475874025.png
still the same old issue with finalik's look at, same counts for aimik
1675475969395.png
Forcing the iktarget here, it snaps right back, I managed to take a screenshot whilst it was jumping back and forth

I'm at a loss here what to do

I also don't understand opsive's solution, since the iktarget that is created gets filled into multiple finalik components, meaning I can't control either finalik component individually, I really do not understand the benefit of this
 
It doesn't look like you are within a trigger - the Look At ability requires a trigger. If you don't want to use a trigger and would rather set the target directly then it'll take a new, similar ability.

The reason the integration works the way it does is to keep it consistent with the operation of the Unity IK component. With that said, I can see how having a look at target being specified directly instead of through a trigger would be useful. I have updated the FinalIK integration so you can now specify if the bridge component should automatically set the Look At or Aim IK target. If you do not enable this property then the controller will not assign the target variable.
 
Hi @Justin , just a quick thought on this, it would be sweet to add a blend between a specified look at transform and the actual UCC/camera look at value. I know your flat out as it is but maybe a note for later :)
 
It doesn't look like you are within a trigger - the Look At ability requires a trigger. If you don't want to use a trigger and would rather set the target directly then it'll take a new, similar ability.

The reason the integration works the way it does is to keep it consistent with the operation of the Unity IK component. With that said, I can see how having a look at target being specified directly instead of through a trigger would be useful. I have updated the FinalIK integration so you can now specify if the bridge component should automatically set the Look At or Aim IK target. If you do not enable this property then the controller will not assign the target variable.
I'm trying literally everything to get this lookat ability to turn active, nothing is working... It's up in the list, there is a trigger in the scene with the right layer and right object id... the state is set to "LookAt" the same state name as in the finalikbridge... The ability index parameter, should that be set to something (set it to the same value, it is still not working, set all of it to 120, still nothing). The bridge has full control yet nothing's happening... I've watched the ability tutorials and read the docs multiple times...

I'm definitely gonna be making changes, but I also want to just understand this system before I do anything...

Removing the trigger to let the state just turn active automatically does not work either.

Am I maybe missing a state preset?

1675700272022.png1675700291443.png
1675700425476.png1675700435549.png
 
Last edited:
@Justin I believe there are errors in the code of LookAt:


Code:
        public override void Awake()
        {
            base.Awake();

            m_CharacterIK = m_GameObject.GetCachedComponent<CharacterIKBase>();
            if (m_Origin == null) {
                var animator = m_GameObject.GetCachedComponent<Animator>();
                if (animator != null) {
                    m_Origin = animator.GetBoneTransform(HumanBodyBones.Head);
                }
                if (m_Origin == null) {
                    m_Origin = m_Transform;
                }
            }

            EventHandler.RegisterEvent<Ability, bool>(m_GameObject, "OnCharacterAbilityActive", OnAbilityActive);
            EventHandler.RegisterEvent<ItemAbility, bool>(m_GameObject, "OnCharacterItemAbilityActive", OnItemAbilityActive);
        }

The GetCachedComponent methods return null. Changing them to GetComponentInChildren fixes for the purposes of testing.
 
@Justin I believe there are errors in the code of LookAt:


Code:
        public override void Awake()
        {
            base.Awake();

            m_CharacterIK = m_GameObject.GetCachedComponent<CharacterIKBase>();
            if (m_Origin == null) {
                var animator = m_GameObject.GetCachedComponent<Animator>();
                if (animator != null) {
                    m_Origin = animator.GetBoneTransform(HumanBodyBones.Head);
                }
                if (m_Origin == null) {
                    m_Origin = m_Transform;
                }
            }

            EventHandler.RegisterEvent<Ability, bool>(m_GameObject, "OnCharacterAbilityActive", OnAbilityActive);
            EventHandler.RegisterEvent<ItemAbility, bool>(m_GameObject, "OnCharacterItemAbilityActive", OnItemAbilityActive);
        }

The GetCachedComponent methods return null. Changing them to GetComponentInChildren fixes for the purposes of testing.
It works now! :)
 
It's nice to see that it works now, but the head does not completely align with the target, even though the weight is set to 1. Even when disabling the bridge and letting the lookat do all the work, something prevents the head from turning all the way. (manipulator shows local orientation of head bone). Just the character fbx added to the scene with a lookat component works 100%.

1675710747198.png
 
@Justin I believe there are errors in the code of LookAt:
Thanks! A similar fix was actually included in 3.0.6 :)

It's nice to see that it works now, but the head does not completely align with the target, even though the weight is set to 1. Even when disabling the bridge and letting the lookat do all the work, something prevents the head from turning all the way. (manipulator shows local orientation of head bone). Just the character fbx added to the scene with a lookat component works 100%.
Is the Look At IK target correct? That almost looks like some type of a FinalIK setting issue. From the character controller side of things once the target has been set it's then up to FinalIK to do the IK repositioning.
 
Thanks! A similar fix was actually included in 3.0.6 :)


Is the Look At IK target correct? That almost looks like some type of a FinalIK setting issue. From the character controller side of things once the target has been set it's then up to FinalIK to do the IK repositioning.
Unlisted video showcasing the problem:

Can't replicate unless components are set before playmode:
Ultimate Character Locomotion Script + FinalIK Bridge = faulty alignment
Ultimate Character Locomotion Script + FinalIK Bridge DELETED = faulty alignment
Ultimate Character Locomotion Script DELETED + FinalIK Bridge DELETED = perfect alignment

And only finalik obv works fine.

Wether these components are set active/inactive does not matter, only if they are on the gameobject.

Small update: (without the bridge but with FinalIK) I turned off every setting on the Ultimate Character Locomotion Script, set everything to zero and removed all abilities, item abilities and states (every subsystem one-by-one, going into and out of playmode) and the issue did not go away until I deleted the script in its entirety. Hope that helps in finding the culprit that still needs to be overrided by the bridge.
 
Last edited:
I don't know why the locomotion matters but try setting the Spine bones under the LookAtIK component. I just tried to reproduce the same issue using the Atlas character and Atlas looked straight at the target. The only difference that I see is that I have set the spine bones:

1675791561160.png
 
I don't know why the locomotion matters but try setting the Spine bones under the LookAtIK component. I just tried to reproduce the same issue using the Atlas character and Atlas looked straight at the target. The only difference that I see is that I have set the spine bones:

View attachment 10303
I just did the same with the atlas character and I am still getting the same issue.
1675798759222.png


Doing nothing weird here either...
1675799247371.png

Update, I reinstalled the asset, opened a clean scene and it's still not working, what am I doing wrong?
1675812426349.png

Using unity 2021.3.17f1
 
Last edited:
Are you running version 3.0.6, which was just released on Monday? The FinalIK integration was also updated with that release. Besides that I can't think of anything that would be different.

I've sent the project to support@opsive.com
I didn't receive that email. Maybe it was too large? In any case I've attached the scene file that I was using for you to compare.
 

Attachments

  • scene.unity
    158.9 KB · Views: 1
Are you running version 3.0.6, which was just released on Monday? The FinalIK integration was also updated with that release. Besides that I can't think of anything that would be different.


I didn't receive that email. Maybe it was too large? In any case I've attached the scene file that I was using for you to compare.
Yes fully up to date. That's weird :(
1675864463368.png
I'll check the scene right away, thank you
 
Last edited:
Your scene file is doing the same. And oddly enough setting the LookAt weights to 1 makes the character look even slightly 'more' offset. :(
1675864789329.png

And here it is again without the locomotion script and without the finalik bridge, still offset but a little better:
1675865159343.png

And here's just the atlas fbx with a lookat component:
1675865285428.png


This would be the desired result...
 
Last edited:
This is Atlas without the locomotion script, with bone rotations zeroed out, this is also without the FinalIK Bridge. perfect alignment:
1675866339076.png
 
Last edited:
Here's the scene with the bones zeroed out and finalik working properly.

I just went into blender and the bone rotations there look fine, all zeroed out. Just a slight rotation on the left leg, but that can't do any harm. Bone orientations also look very neat, all-in-all a fine rigging job. Fbx is exported just fine too. Without the locomotion and bridge script, things work fine.

I just fixed the avatar configuration by zeroing out the spine, also took out the -90 rotations. And brought the ORG-hips to (0, 1, 0) position. Also applied the same on the prefab's model of the character. Without the locomotion and bridge script, and zeroed out values, the alignment on the Atlas prefab is absolutely perfect. With those scripts, and the avatar's bones having zeroed values, the head is still slanted and things don't behave well at all. Without those scripts, and with the avatar's bone rotations zeroed out, the head aligns perfectly...

Also, just the pure Atlas FBX dropped into a scene with all of its unfixed original bone rotations and -90 blender rotation works perfectly fine as well with a FinalIK LookAt.

So it could very well be it's not the bone rotations at all... Or it's both... But it surely is code-related.

1675872748913.png
On the Atlas Prefab, without loco & bridge, zeroed out spine/neck/head
 

Attachments

  • scene with fix.unity
    132.5 KB · Views: 0
Last edited:
Top