码迷,mamicode.com
首页 > 编程语言 > 详细

Unity杂记

时间:2020-02-10 13:25:44      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:col   switch   velocity   ==   else   state   mat   style   lse   

    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杂记

标签:col   switch   velocity   ==   else   state   mat   style   lse   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!