Unity's new animation system animation state machine Animator Controller

1. Create animation state machine file

(1) Will be automatically created when creating animation

(2)Create----Animator Controller

2. Animation state machine window related

Level: You can set the parameter size in the gear on the right 

 3. Add animation

Animating an object is automatically added to the state machine

4. Status switching

The animation will continuously switch between 1 and 2

 add condition

Click the conversion arrow

 Set conditions here

5. Code-controlled animation switching

(1) Animator component

(2) Animator API

        if (Input.GetKeyDown(KeyCode.A))
        {
            animator.SetFloat("条件名", 1.2f);

        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            animator.SetInteger("条件名", 1);
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            animator.SetBool("条件名", true);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            animator.SetTrigger("条件名");
        }

        //得到值
        animator.GetFloat("条件名");

(3) Switch animation exit time Exit Time

If checked, the animation will be switched after the animation is played. If not checked, the animation will be switched immediately.

Guess you like

Origin blog.csdn.net/holens01/article/details/130931717