Unity杂记

Posted howld

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity杂记相关的知识,希望对你有一定的参考价值。

    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杂记的主要内容,如果未能解决你的问题,请参考以下文章

Unity3D的杂记

Unity游戏开发AssetBundle杂记--AssetBundle的二三事

Unity报错:Read only asset Packages/com.xxxxx.xxx.xxxx/Editor/VSCodeDiscovery.cs.IPGSD has no meta(代码片段

Unity报错:Read only asset Packages/com.xxxxx.xxx.xxxx/Editor/VSCodeDiscovery.cs.IPGSD has no meta(代码片段

Unity中获取Animator中动画片段的时长

unity动画一个片段播放完怎么让它不会到初始状态