- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
 
- 纳金币
- 53488
- 精华
- 316
|
再我们做游戏时,有事需要在角色动画播放到一定事件做特定的事情(比如角色的攻击动画时长为1s,但我们需要向玩家展示角色攻击动画在0.5s的动作状态,此时我们就可以在动画播放到0.5s时进行stop)
public class AnimationCtr:MonoBehaviour
{
public Animation animation;
void Start ()
{
//首先定义动画事件
AnimationEvent _event = new AnimationEvent ();
//设置事件触发时间
_event.time = anim.GetClip ("attack").length - 0.1f;
//设置事件回调方法
_event.functionName = "attackStop";
//添加此动画事件到动画剪辑中
anim.GetClip ("attack").AddEvent (_event);
}
//此为事件回调方法
void attackStop()
{
//TODO
}
|
|