找回密码
 立即注册
查看: 238|回复: 0

unity 动画插件 Animancer

[复制链接]
发表于 2022-10-23 16:13 | 显示全部楼层 |阅读模式
去asset store下个Animancer Lite                                       
给角色挂个Animancer Component,Animator选自己
创建个脚本控制动作切换,对比unity自带的Animator Control这个动作切换就不会有间隔。
public class TestAnimancer : MonoBehaviour                                       
{                                       
    public AnimancerComponent _Animancer;                                       
    public AnimationClip _Idle;                                       
    public AnimationClip _Action;                                       
    bool b;                                       
                    
    private void Start()                                       
    {                                       
        b = true;                                       
    }                                       
                    
    private void OnEnable()                                       
    {                                       
        _Animancer.Play(_Idle);                                       
    }                                       
                    
    private void Update()                                       
    {                                       
        if (Input.GetMouseButtonDown(0))                                       
        {                                       
            if (b)                                       
            {                                       
                var state = _Animancer.Play(_Action);                                       
                //state.Events.OnEnd = OnActionEnd; //动画播放完后回调函数                                       
            }                                       
            else                                       
            {                                       
                _Animancer.Play(_Idle);                                       
            }                                       
                    
            b = !b;                                       
        }                                       
    }                                       
                    
    private void OnActionEnd()                                       
    {                                       
        _Animancer.Play(_Idle, 0.25f);                                       
    }                                       
}
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-11 04:57 , Processed in 0.088654 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表