官方 Animator 例子解析 Animator.MatchTarget
一、官方的解释
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的更多相关文章
- Poco库网络模块例子解析1-------字典查询
Poco的网络模块在Poco::Net名字空间下定义 下面是字典例子解析 #include "Poco/Net/StreamSocket.h" //流式套接字 #include ...
- Tensorflow-hub[例子解析2]
接Tensorflow-hub[例子解析1]. 3 基于文本词向量的例子 3.1 创建Module 可以从Tensorflow-hub[例子解析1].中看出,hub相对之前减少了更多的工作量. 首先, ...
- Java字节码例子解析
举个简单的例子: public class Hello { public static void main(String[] args) { String string1 = ...
- Poco C++库网络模块例子解析2-------HttpServer
//下面程序取自 Poco 库的Net模块例子----HTTPServer 下面开始解析代码 #include "Poco/Net/HTTPServer.h" //继承自TCPSe ...
- 持续集成环境Gitlab-CI的官方安装过程解析
持续集成环境是一个非常重要的工具,在分工合作的项目中有着举足轻重的作用.公司最近要用Gitlab,需要配套的持续集成环境.研究了官方的文档,感觉官方的文档不是很明了.各种修改过后终于成功了.为了大家安 ...
- Tensorflow-hub[例子解析1]
0. 引言 Tensorflow于1.7之后推出了tensorflow hub,其是一个适合于迁移学习的部分,主要通过将tensorflow的训练好的模型进行模块划分,并可以再次加以利用.不过介于推出 ...
- PHP-会员登录与注册例子解析-学习笔记
1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...
- java 20 - 4 IO流概述和一个简单例子解析
IO流的分类: 流向: 输入流 读取数据 输出流 写出数据 数据类型: 字节流 字节输入流 读取数据 InputStream 字节输出流 写出数据 OutputStream 字符流 字符 ...
- LUA 捕获模式 URL编码的例子解析
function escape(s) s=string.gsub(s,"([&=+%c])",function(c) return string.format(" ...
随机推荐
- Coarse-Grained lock 粗粒度锁
用一个锁Lock一组相关的对象 有时,需要按组来修改多个对象. 这样,在需要锁住其中一个的时候,必须连带地将其他的对象都上锁. 为每一个对象都加上一个锁是很繁琐的. 粗粒度锁是覆盖多个对象的单个锁. ...
- javaweb毕业设计
javaweb毕业设计,管理系统设计,Strut2项目,Springmvc项目,javaweb项目学习. 都是可以运行的,(配数据库和论文),都能提供技术咨询,可以修改.欢迎+扣扣396058587咨 ...
- [转]高并发访问下避免对象缓存失效引发Dogpile效应
避免Redis/Memcached缓存失效引发Dogpile效应 Redis/Memcached高并发访问下的缓存失效时可能产生Dogpile效应(Cache Stampede效应). 推荐阅读:高并 ...
- 【转】MyEclipse快捷键大全(绝对全)
ref:http://www.douban.com/note/254195820/?type=like# ctrl+w 关闭单个窗口 F3 跳转到类.变量的声明 F11 运行上次程序 Ctrl + F ...
- 利用Jmeter做接口测试
本文作者:大道测试团队-孙云 1.在安装jmeter之前先配置好JDK,再配置jmeter环境变量. 2.启动jmeter 启动jmeter: 双击Jmeter解压路径(apache-jmeter-3 ...
- opencv的初体验
http://guoming.me/opencv-config 这篇文章有讲解opencv的安装与配置 一些常用库 opencv_core249d.lib opencv_imgproc249d.li ...
- Teradata 的rank() 和 row_number() 函数
Teradata数据库中也有和oracle类似的分析函数,功能基本一样.示例如下: RANK() 函数 SELECT * FROM salestbl ORDER BY 1,2; storeid p ...
- (转)MapReduce中的两表join几种方案简介
转自:http://blog.csdn.net/leoleocmm/article/details/8602081 1. 概述 在传统数据库(如:MYSQL)中,JOIN操作是非常常见且非常耗时的.而 ...
- WPF-控件-ControlTemplate生成的控件
<Window x:Class="由ControlTemplate生成的控件.MainWindow" xmlns="http://schemas.microsoft ...
- dblink 的源数据表结构修改后在存储过程里执行报错
原情况:A服务器表A服务器B也有一张表A服务器B上有一个存储过程要把本地的head表向A服务器表里插入数据.变更后:在A服务器表里增加了一个字段inserttime,服务器B存储过程本地表向A服务器插 ...