返回介绍

AnimationState.AddMixingTransform 添加混合Transform

发布于 2019-12-18 15:37:13 字数 3308 浏览 1026 评论 0 收藏 0

JavaScript => public function AddMixingTransform(mix: Transform, recursive: bool = true): void;
C# => public void AddMixingTransform(Transform mix, bool recursive = true);

Parameters 参数

mixThe transform to animate.
动画变换。
recursiveWhether to also animate all children of the specified transform.
是否动画所有子物体指定变换。

Description 描述

Adds a transform which should be animated. This allows you to reduce the number of animations you have to create.

添加应该动画的变换。这允许你减少创建的动画的数量。

For example you might have a handwaving animation. You might want to play the hand waving animation on a idle character or on a walking character. Either you have to create 2 hand waving animations one for idle, one for walking. By using mixing the hand waving animation will have full control of the shoulder. But the lower body will not be affected by it, and continue playing the idle or walk animation. Thus you only need one hand waving animation.

例如你可能挥手动画。你可能想在闲置角色或者走动角色上去播放挥手动画。你需要创建2个挥手动画一个给闲置的,一个给走动的。通过混合挥手动画将会完全控制肩膀。但是他可能影响不到更低的身体,并继续包房走动或者闲置的动画。因此你仅需要一个挥手动画。

If recursive is true all children of the mix transform will also be animated. If you don't call AddMixingTransform, all animation curves will be used.

如果recursive 是true 所有子物体的混合transform将会被逼真。如果你调用AddMixingTransform,所有动画曲线被使用。

JavaScript:

#pragma strict
public class ExampleScript extends MonoBehaviour {
	public var anim: Animation;
	public var shoulder: Transform;
	function Start() {
		// Add mixing transform
		anim["wave_hand"].AddMixingTransform(shoulder);
	}
}

Another example using a path: JavaScript:

#pragma strict
public class ExampleScript extends MonoBehaviour {
	public var anim: Animation;
	function Start() {
		// Adds a mixing transform using a path instead
		var mixTransform: Transform = transform.Find("root/upper_body/left_shoulder");
		// Add mixing transform
		anim["wave_hand"].AddMixingTransform(mixTransform);
	}
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleScript : MonoBehaviour
{
    public Animation anim;
    public Transform shoulder;
 
    void Start()
    {
        // Add mixing transform
        anim["wave_hand"].AddMixingTransform(shoulder);
    }
}

Another example using a path: C#:

using UnityEngine;
using System.Collections;
 
public class ExampleScript : MonoBehaviour
{
    public Animation anim;
 
    void Start()
    {
        // Adds a mixing transform using a path instead
        Transform mixTransform = transform.Find("root/upper_body/left_shoulder");
 
        // Add mixing transform
        anim["wave_hand"].AddMixingTransform(mixTransform);
    }
}

animationstate

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文