zoukankan      html  css  js  c++  java
  • 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是相对于当前动画的匹配开始,结束时间。

  • 相关阅读:
    Maven介绍及安装与配置
    Xshell使用技巧总结
    UML类图
    vim使用案例
    Linux常用命令3(压缩和解压缩总结)
    Linux常用命令2(远程文件下载+查看文件内容)
    Linux常用命令1
    JOptionPane类提示框常用方法总结
    HTTP基础知识3
    HTTP基础知识2
  • 原文地址:https://www.cnblogs.com/hont/p/5095895.html
Copyright © 2011-2022 走看看