攻动画与被攻击动画如何联动、衔接呢?可以使用Playable Director & Timelline Asset解决。
【导演】Playable Director
Playable Director 简单理解为导演,它存储了Timeline实例(Timeline instance)与Timeline资源(Timeline Asset)间的连接。控制Timeline何时播放,如何更新时钟(clock)等。
Timeline则控制了Timeline Asset的联动进行。
关于组件属性
Unity - Timeline 之 Playable Director component(Playable Director组件)
【剧本】Timeline
左边轨道理解为【演员】,右边轨道理解为具体的【表演动作】。
如何动态修改【演员】
using UnityEngine.Playables;
public PlayableDirector pd;
public Animator attacker;
public Animator victim;
void Update()
{
if (Input.GetKeyDown(KeyCode.H)){
foreach (var track in pd.playableAsset.outputs)
{
if(track.streamName == "Attacker Animation")
{
pd.SetGenericBinding(track.sourceObject, attacker);
}
else if(track.streamName == "Victim Animation")
{
pd.SetGenericBinding(track.sourceObject, victim);
}
}
pd.Play();
}
}
Timeline
About Timeline
|