一、官方的解释

 Animator.MatchTargetSwitch to Manual
void MatchTarget(Vector3 matchPosition, Quaternion matchRotation, AvatarTarget targetBodyPart, MatchTargetWeightMask weightMask, float startNormalizedTime, float targetNormalizedTime = );
Parameters matchPosition The position we want the body part to reach.
matchRotation The rotation in which we want the body part to be.
targetBodyPart The body part that is involved in the match.
weightMask Structure that contains weights for matching position and rotation.
startNormalizedTime Start time within the animation clip ( - beginning of clip, - end of clip).
targetNormalizedTime End time within the animation clip ( - beginning of clip, - end of clip), values greater than can be set to trigger a match after a certain number of loops. Ex: 2.3 means at % of 2nd loop.
Description Automatically adjust the gameobject position and rotation so that the AvatarTarget reaches the matchPosition when the current state is at the specified progress. Target matching only works on the base layer (index ).

二、理解

这个 一般 用于 根运动 动画。 可以用在 人物攀爬 或者 掉落 的动画 时候 进行一些 位置的调整。具体在于理解。上一段官方的例子教程。

 using UnityEngine;
using System.Collections; public class TargetMatching : MonoBehaviour
{ private Animator animator;
/// <summary>
/// 匹配 目标
/// </summary>
public Transform RightHand;
bool hasJumped = false; // Use this for initialization
void Start () { animator = GetComponent<Animator>(); } void OnGUI()
{
GUILayout.Label("Make your character grab any edge!");
GUILayout.Label("Press Fire1 to trigger Jump animation");
GUILayout.Label("Added *MatchStart* and *MatchEnd* parameters to the Animator Controller");
GUILayout.Label("Added *MatchStart* and *MatchEnd* additionnal curves to the Idle_ToJumpUpHigh animation");
GUILayout.Label("*MatchStart* and *MatchEnd* tell the system when to start cheating the root using MatchTarget API");
GUILayout.Label("Added a RightHand model child of the MoveThis container, to tell where the right hand should go");
GUILayout.Label("On the update function, we call MatchTarget");
GUILayout.Label("Translate the MoveThis object and see how character's hand always reach it");
} // Update is called once per frame
void Update ()
{ if (animator)
{
AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(); if (Input.GetButton("Fire1")) animator.SetBool("Jump", true); if (state.IsName("Base Layer.JumpUp") || state.IsName("Base Layer.FullJump"))
{
animator.SetBool("Jump", false); animator.MatchTarget(
RightHand.position,
RightHand.rotation,
AvatarTarget.RightHand,
new MatchTargetWeightMask(new Vector3(, , ), ),
/// 动画 曲线 获取
animator.GetFloat("MatchStart"),
animator.GetFloat("MatchEnd"));
hasJumped = true;
} if (hasJumped && state.normalizedTime > 1.2)
{
hasJumped = false; Application.LoadLevel();
} Debug.Log(" animator.GetFloat MatchStart " + animator.GetFloat("MatchStart") + " state.normalizedTime " + state.normalizedTime);
} }
}

官方 Animator 例子解析 Animator.MatchTarget的更多相关文章

  1. Poco库网络模块例子解析1-------字典查询

    Poco的网络模块在Poco::Net名字空间下定义   下面是字典例子解析 #include "Poco/Net/StreamSocket.h" //流式套接字 #include ...

  2. Tensorflow-hub[例子解析2]

    接Tensorflow-hub[例子解析1]. 3 基于文本词向量的例子 3.1 创建Module 可以从Tensorflow-hub[例子解析1].中看出,hub相对之前减少了更多的工作量. 首先, ...

  3. Java字节码例子解析

    举个简单的例子: public class Hello {     public static void main(String[] args) {         String string1 = ...

  4. Poco C++库网络模块例子解析2-------HttpServer

    //下面程序取自 Poco 库的Net模块例子----HTTPServer 下面开始解析代码 #include "Poco/Net/HTTPServer.h" //继承自TCPSe ...

  5. 持续集成环境Gitlab-CI的官方安装过程解析

    持续集成环境是一个非常重要的工具,在分工合作的项目中有着举足轻重的作用.公司最近要用Gitlab,需要配套的持续集成环境.研究了官方的文档,感觉官方的文档不是很明了.各种修改过后终于成功了.为了大家安 ...

  6. Tensorflow-hub[例子解析1]

    0. 引言 Tensorflow于1.7之后推出了tensorflow hub,其是一个适合于迁移学习的部分,主要通过将tensorflow的训练好的模型进行模块划分,并可以再次加以利用.不过介于推出 ...

  7. PHP-会员登录与注册例子解析-学习笔记

    1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...

  8. java 20 - 4 IO流概述和一个简单例子解析

    IO流的分类:  流向: 输入流 读取数据  输出流 写出数据 数据类型:  字节流  字节输入流 读取数据 InputStream  字节输出流 写出数据 OutputStream  字符流  字符 ...

  9. LUA 捕获模式 URL编码的例子解析

    function escape(s) s=string.gsub(s,"([&=+%c])",function(c) return string.format(" ...

随机推荐

  1. CXF调用wsdl2java生成客户端异常

    用cxf生成java客户端代码的时候出现异常: undefined element declaration 's:schema'   解决办法:1.删除   2.替换   参考资料:   http:/ ...

  2. Java 字符流实现文件读写操作(FileReader-FileWriter)

    Java 字符流实现文件读写操作(FileReader-FileWriter) 备注:字符流效率高,但是没有字节流底层 字节流地址:http://pengyan5945.iteye.com/blog/ ...

  3. 济南学习 Day 2 T2 pm

    她[问题描述]给你L,R,S,M,求满足L≤ (S × x) mod M ≤ R最小的正整数 X.[输入格式]第一行一个数T代表数据组数.接下来一行每行四个数代表该组数据的L,R,S,M.[输出格式] ...

  4. mysql max_allowed_packet自动重置为1024 终结解决

    背景: 测试环境1台centOS机器,最近一段频繁报“ Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too ...

  5. hadoop2.2.0伪分布式搭建

    1.准备Linux环境     1.0点击VMware快捷方式,右键打开文件所在位置 -> 双击vmnetcfg.exe -> VMnet1 host-only ->修改subnet ...

  6. Redis 一:安装篇

    .安装环境,虚拟机 + centos6. PS::前提已经安装了yum的情况下 第一步:安装 mkdir /usr/redis 新建redis目录 cd /usr/redis 进入目录 wget ht ...

  7. python time模块和datetime模块详解

    一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...

  8. 【转】你需要知道的Python用法

    在使用Python多年以后,我偶然发现了一些我们过去不知道的功能和特性.一些可以说是非常有用,但却没有充分利用.考虑到这一点,我编辑了一些的你应该了解的Pyghon功能特色. 带任意数量参数的函数 你 ...

  9. Golang学习笔记

    一.基础 1. Hello World程序 demo: package main import "fmt" // 注释 //注释 func main() { fmt.Printf( ...

  10. 【转】Mac 上 java 究竟在哪里,本文彻底让你搞清楚!

    这篇文章可能比较适合那些在经常在Mac下进行Java编程开发,或者经常使用Java工具的朋友.不关心Java或者不了解Java的朋友可以绕过本文哈~ 1. Mac下当你在[终端]输入java -ver ...