首页 > 编程语言 > 详细

Unity杂记

时间:2020-02-10 15:20:47      阅读:76      评论:0      收藏:0      [点我收藏+]
    void SwitchAnim()
    {
        if (isGround)
        {
            if (state != State.PlayerIdle && ((state == State.PlayerRun && Mathf.Abs(rb.velocity.x) < 0.01f) || state == State.PlayerFall))
            {
                anim.SetTrigger("PlayerIdle");
                state = State.PlayerIdle;
            }
            else if (state != State.PlayerRun && (state == State.PlayerIdle && Mathf.Abs(rb.velocity.x) > 0.01f))
            { 
                anim.SetTrigger("PlayerRun");
                state = State.PlayerRun;
            }
        }
        else if (!isGround)
        {
            if (state != State.PlayerJump && (state == State.PlayerIdle || state == State.PlayerRun || state == State.PlayerFall))
            {
                if (rb.velocity.y > 0)
                { 
                    anim.SetTrigger("PlayerJump");
                    state = State.PlayerJump;
                }
            }
            else if (state != State.PlayerFall && (state == State.PlayerJump || state == State.PlayerIdle || state == State.PlayerRun))
            {
                if (rb.velocity.y < 0)
                {
                    anim.SetTrigger("PlayerFall");
                    state = State.PlayerFall;
                }
            }
        }
    }
}

 

Unity杂记

原文:https://www.cnblogs.com/howld/p/12290548.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!