I'm trying to write a piece of custom code to turn on and off Inverse kinematics for a characters hands based on what animations they're doing. I'm using the inverse kinematics to attach/detach a characters hands from the handle of a weapon. The weapon is equipped through ORK's normal equipment management system and shown through an equipment viewer component. All of the ORK side of things works just fine. I'm writing the code because some of the animations I'm using don't work exactly right with the model I'm using and I'm using inverse kinematics to fix that.

So here is where I need some help on the ORK side of things: the weapon (and therefore the empty game objects whose transforms are the IK targets for the hands) isn't present in the scene until the start of a fight, and can potentially be switched around. So I'm trying to write a script that assigns the transform variables in my IK control script during the game when the weapon is equipped. For that, I think the best way to do it would probably be to have the "equip" event tell my ik control script that the item is equiped and what the IK targets are. But I'm not entirely sure how to do that, where to go to edit those scripts, etc.
  • Are you using Final IK?
    The way I did it was writing the IK Manager for characters where you can sort of build IK State's like: image
    Then (Credits go to @Keldryn ) I'm calling the states for equipping the weapon, by attaching a script to the Weapon/Armor game object prefabs. Then in Start function of that script I'm Setting the IK State. When the object(Weapon/Armor) get's spawned this script get's called and you can setup everything like you want.

    It looks like this for me
    void Start()
    IKManager = transform.root.GetComponent<IKManager>();
    AnimationManager = transform.root.GetComponent<AnimationManager>();

    if (EnableWeaponType)
    if (AnimationManager != null)
    Debug.LogWarning(transform.root.name + "No Animation Manager Component Found");
    Invoke("DelayedPlay", 0.2f);


    void OnDestroy()
    PlayEvent(OnUnEquipAnimationEventName, OnUnEquipDirectIKEventName, OnUnEquipUseAnimationEvent);

    And to set IK state on specific animations (again credits go to @Keldryn) I'm using the StateMachine Behaviors(https://docs.unity3d.com/ScriptReference/StateMachineBehaviour.html), which are the scripts you can attach to Animator States and I'm triggering my IK stuff from there.
    public class AnimStateTrigger : StateMachineBehaviour

    public string IKState;
    IKManager Manager;
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    if (!string.IsNullOrEmpty(IKState))

    Manager = animator.GetComponent<IKManager>();
    if (Manager != null)
Sign In or Register to comment.