AnimationState.AddMixingTransform 添加混合变换

function AddMixingTransform (mix : Transform, recursive : bool = true) : void

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.

例如你可能有一个挥手(hand-waving)动画. 你可能需要让一个空闲站立(idle)角色或者一个走动(walking)角色 来挥手. 如果没有动画混合你可能需要制作两个挥手hand-waving动画 : 一个给 idle, 一个给walking. 可是, 如果你将挥手(hand-waving)动画作为一个mixing transform 添加到shoulder transform,挥手动画将只控制肩膀. 身体余下部位不受其影响, 下半身会继续播放 idle 或者 walk 动画. 因而你只需要一个挥手(hand-waving)动画.

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.

如果循环模式为true所有混合transform的子项将动画处理。如果你不调用AddMixingTransform,所有的动画曲线将被使用.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Transform shoulder;
	public void Awake() {
		animation["wave_hand"].AddMixingTransform(shoulder);
	}
}
// Adds a mixing transform using a path instead
// 不用路径增加一个混合transform

var shoulder : Transform ;
animation["wave_hand"].AddMixingTransform(shoulder);

另一个例子:

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Start() {
		Transform mixTransform = transform.Find("root/upper_body/left_shoulder");
		animation["wave_hand"].AddMixingTransform(mixTransform);
	}
}
function Start () {
	// Adds a mixing transform using a path
	// 用路径增加一个混合transform
	var mixTransform : Transform = transform.Find("root/upper_body/left_shoulder");
	animation["wave_hand"].AddMixingTransform(mixTransform);
}
最后修改:2011年4月28日 Thursday 14:09

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。