• Unity-Animator深入系列---目标匹配Target Matching


    回到 Animator深入系列总目录

    一开始会理所当然的觉得,匹配是这样的:

    但结果却是这样的(右边的Cube是匹配目标):

    感觉这个接口应该是专门为攀爬之类的动画准备的,属于被动匹配位置,移动整个对象去匹配

    所以像游戏中的斜面双脚的IK匹配,就和这个接口没关系了:

     

    OK,下面附上测试代码:

    using UnityEngine;
    
    public class MatchTargetExample : MonoBehaviour
    {
        public Animator animator;
        public GameObject testTarget;
    
    
        [ContextMenu("Start Match")]
        void StartMatch()
        {
            animator.MatchTarget(testTarget.transform.position, testTarget.transform.rotation, AvatarTarget.LeftHand, new MatchTargetWeightMask(Vector3.one, 1f), 0f);
        }
    
        [ContextMenu("Interrupt Match Target")]
        void InterruptMatchTarget()
        {
            animator.InterruptMatchTarget();
        }
    }
    MatchTargetExample

    使用方式:

    1.TargetMatching只能工作在base layer

    2.InterruptMatchTarget中的completeMatch设为True的话,会立即结束插值自动跳到目标匹配位置。

    3.MatchTargetWeightMask是和原有动画之间的权重,如果为1就是完全控制。

    4.isMatchingTarget字段确定当前是否在匹配状态

    5.startNormalizedTime和targetNormalizedTime是相对于当前动画的匹配开始,结束时间。

  • 相关阅读:
    hadoopnamenode配置及问题处理方案
    hadoop 运行 Java程序
    hadoop命令大全
    DOS
    腾讯Linux QQ安装
    linux下安装realplayer
    在linux中配置安装telnet服务
    关于C#静态构造函数的几点说明
    linux下的Network File Server共享配置
    Oracle学习笔记
  • 原文地址:https://www.cnblogs.com/hont/p/5095895.html
Copyright © 2020-2023  润新知