• Unity-Animator深入系列---控制IK


    回到 Animator深入系列总目录

    要让代码控制IK,需要先在Animator中打开IK pass

    然后,和IK相关的代码需要放到相应的函数中去:

    void OnAnimatorIK()
    {
        Debug.Log("OnAnimatorIK");
    }

    而如果是StateMachineBehaviour,IK操控的代码是在:

    public override void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnStateIK(animator, stateInfo, layerIndex);
    
        Debug.Log("OnStateIK");
    }

    测试脚本:

    using UnityEngine;
    using System.Collections;
    
    public class IKTest : MonoBehaviour
    {
        public Animator animator;
        public Transform ikTarget;
    
    
        void OnAnimatorIK()
        {
            animator.SetIKPosition(AvatarIKGoal.LeftFoot, ikTarget.position);
            animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, 1);
        }
    }
    View Code
  • 相关阅读:
    sql
    java常见异常
    call的用法及NodeList与Array的区别
    os模块
    random模块
    time模块
    序列化模块
    模块介绍
    内置函数
    匿名函数-lambda
  • 原文地址:https://www.cnblogs.com/hont/p/5096855.html
Copyright © 2020-2023  润新知