UnityAPI手册-2019.4官网版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Animator.MatchTarget
# [Animator](Animator.html).MatchTarget public void **MatchTarget** ([Vector3](Vector3.html) **matchPosition**, [Quaternion](Quaternion.html) **matchRotation**, [AvatarTarget](AvatarTarget.html) **targetBodyPart**, [MatchTargetWeightMask](MatchTargetWeightMask.html) **weightMask**, float **startNormalizedTime**, float **targetNormalizedTime**= 1); ## 参数 | matchPosition | 我们希望身体部位到达的位置。 | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | matchRotation | 我们希望身体部位进行的旋转。 | | targetBodyPart | 匹配中涉及的身体部位。 | | weightMask | 包含匹配位置和旋转的权重的结构。 | | startNormalizedTime | 动画剪辑中的开始时间(0 - 剪辑开头,1 - 剪辑末尾)。 | | targetNormalizedTime | 动画剪辑中的结束时间(0 - 剪辑开头,1 - 剪辑末尾),可以设置为大于 1 的值,以在循环一定次数后触发匹配。例如:2.3 表示在第二次循环的 30% 处触发匹配。 | ## 描述 自动调整 `GameObject` 的位置和旋转。 调整 `GameObject` 的位置和旋转,以便当前状态处于指定的进度时,AvatarTarget 到达 matchPosition。目标匹配仅适用于基础层(索引 0)。 一次只能排队一个匹配目标,并且必须等待第一个匹配目标完成,否则将丢弃目标匹配。 如果调用 [MatchTarget](Animator.MatchTarget.html) 的开始时间小于剪辑的当前标准化时间并且剪辑可以循环,[MatchTarget](Animator.MatchTarget.html) 将调整时间以匹配下一个剪辑循环。例如:开始时间 = 0.2,当前标准化时间 = 0.3,则开始时间将为 1.2。必须启用 [Animator.applyRootMotion](Animator-applyRootMotion.html) MatchTarget 才会有效。 ``` using UnityEngine; public class TargetMatchingManager : MonoBehaviour { public void MatchTarget(Vector3 matchPosition, Quaternion matchRotation, AvatarTarget target, MatchTargetWeightMask weightMask, float normalisedStartTime, float normalisedEndTime) { var animator = GetComponent<Animator>(); if (animator.isMatchingTarget) return; float normalizeTime = Mathf.Repeat(animator.GetCurrentAnimatorStateInfo(0).normalizedTime, 1f); if (normalizeTime > normalisedEndTime) return; animator.MatchTarget(matchPosition, matchRotation, target, weightMask, normalisedStartTime, normalisedEndTime); } } ```
da
2022年5月24日 00:05
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码