Please help with IK Hand Positions - Reloading STATES section

JohnG

Member
Hi,

@Justin I am desperately struggling with sorting out states for reloading by following the instructions here:


The section of the instructions I am pulling my hair out on, is the following:

When using this method to position the character’s non-dominant hand they will have a problem reloading because the IK system will keep their hand in place. You can use the state system to set the Hand Weight of the CharacterIK component to 0 when the Reload ability is active.

I just don't know where to do this, the state system is extremely confusing to me even after watching your videos and reading your instructions.

I have tried to add a state to the "ThirdPersonPerspectiveItem.cs" script on the weapon, however when I create a state the add property button is grayed out. I also am not sure if this is the correct place to add the state.

I am using FinaliK, everything installed correctly with the bridge component, etc.
 
I solved this issue a different way (the reload hand weight). As per the above, I am using FinalIK:

C#:
    public void WhatItemAbility(ItemAbility itemAbility, bool activated)
    {
        if (itemAbility.InputNames[0] == "Reload")
        {
            if (activated)
            {
                ik.solver.leftHandEffector.positionWeight = 0;
            }
            else
            {
                ik.solver.leftHandEffector.positionWeight = 1;
            }
//            ik.solver.leftHandEffector.positionWeight = 0;
            Debug.Log("Start Reload " + itemAbility.InputNames[0] + " " + activated + " " + ik.solver.leftHandEffector.positionWeight);
        }
    }

    private void Awake()
    {
        //EventHandler.RegisterEvent(m_GameObject, "OnAnimatorItemReloadComplete", OnItemReloadComplete);

        EventHandler.RegisterEvent<ItemAbility,bool>(gameObject, "OnCharacterItemAbilityActive", WhatItemAbility);
    }

The code is probably ugly, if anyone want to improve on it please do so.

It works well, now the left hand is not stuck on the weapon when reloading.

EDIT: Add WhatItemAbility to "On Item Ability Active Event" within UltimateCharacterLocomotion section of the character.
 
Last edited:
For adding a state preset:

- To add a state preset that gets activated during the reload ability, you first need to check what state gets activated when that ability is used: open the character's "Item Abilities" and check the Reload ability's "State" property (in the demo scene it's simply "Reload").
- Then open up the character's CharacterIK component's "States". You'd add a state here by clicking the "+", "Create New Preset" and name and save your preset somewhere. Set the "Name" property of your newly added state preset to the reload state name, e.g. "Reload".
- Then open up that state's preset, and the "Add Property" dropdown should have the "Hand Weight" property. Then just apply whatever value you need to the hand weight.
 
For adding a state preset:

- To add a state preset that gets activated during the reload ability, you first need to check what state gets activated when that ability is used: open the character's "Item Abilities" and check the Reload ability's "State" property (in the demo scene it's simply "Reload").
- Then open up the character's CharacterIK component's "States". You'd add a state here by clicking the "+", "Create New Preset" and name and save your preset somewhere. Set the "Name" property of your newly added state preset to the reload state name, e.g. "Reload".
- Then open up that state's preset, and the "Add Property" dropdown should have the "Hand Weight" property. Then just apply whatever value you need to the hand weight.

This is with unity standard ik correct? I dont know how to do your method using finalik.
 
Ah, my apologies, didn't see that you're using Final IK. I've not used Final IK before so I'm not familiar with the exact process of settings up states with it, so I'll pass this on to Justin to see if he knows more about it than me.
 
Unfortunately FinalIK does not support the state system so you'll need to change the properties manually through script.
 
Unfortunately FinalIK does not support the state system so you'll need to change the properties manually through script.
creating a new state and attach a code reffering to final iks system to set hand weight to 0 ?
 
You could create a state and then check for that state being active in code. E.g.:

Code:
var locomotion = GetComponent<UltimateCharacterLocomotion>();
var aimState = System.Array.Find(locomotion.States, state => state.Name == "Aim");
if (aimState != null && aimState.Active) {
    // ...
}
 
Yep unfortunately as Justin said FinalIK does not support the state system directly.
 
Okay I have to try to figure out that later.. I was anyways just thinking about to only use puppet master (förr falling, tripping on obstacles, banging head, and ragdoll) .. and final IK for foot placement.. and just use opsives solution for IK aim.
 
Top