• Unity
  • Change Ik mix in RealTime

  • تم التحرير
Related Discussions
...

Hello,

We are having trouble finding this call to change the IK Mix in RealTime, or even, Null the IK completely.
In the case of nulling, will the animation overlap the code?

If someone could help would be great!
Thanks.


Ok just founded.

If this helps someone, here is the CODE:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Spine;
using Spine.Unity;
using Spine.Unity.Modules;


public class MecanimSpine_SkeletonManager : MonoBehaviour
{
    //Skeleton
    SkeletonUtility skel;

void Start()
{
  skel = GetComponent<SkeletonUtility>();
}

void SetIKMix(string IKname, float mixValue)
{
  skel.skeletonAnimation.Skeleton.FindIkConstraint(IKname).mix = mixValue;
}
 
}

It can be accessed as follows:

SkeletonAnimation skeletonAnimation;
...
foreach (var constraint in skeletonAnimation.Skeleton.IkConstraints) {
    if (constraint.Data.Name == "aim") {
        constraint.Mix = 0.5f;
    }
}

Or, assuming you know the constraint named aim is there:

skeletonAnimation.Skeleton.FindIkConstraint("aim").Mix = 0.5f;

See:
spine-runtimes/Skeleton.cs at 3.7
And:
Skeleton findIkConstraint