Animator Windows View Project View Playeridleanimation and Playerwalkinganimation

Source: Internet
Author: User

Animator Windows View Project View Playeridleanimation and Playerwalkinganimation

With the previous section, we created 2 new animations: Playeridleanimation and Playerwalkinganimation. And when you click the Play button in the animation view, you also see the effect of the animation. But now also need to manage these two animations, that is, you need to be able to specify the current animation state of the Sprite, you need to expand the animation controller to set up and operation, the specific steps are selected from the Unity 2D game development from the beginner to proficient in Tsinghua University Press :

(1) In Project view, find the animation controller that was generated when the animation was created, and in this example its name is Playeranimatorcontroller. Double-click on it and then pop up the animator window view, which contains 3 animation states, the animation state named "Any" is system generated, and the other two animation states are defined in the previous section, as shown in 1-23.

Figure 1-23 3 animation states in the animator view

(2) Right-click on the Playeridleanimation animation state, then select Make Transition in the popup shortcut menu, and then the Playerwalkinganimation animation state. This adds an arrow from the former to the latter, which represents the transition of the two animation states, that is, the animation state that is represented by the animation state transition from the former. Using the same method, add the transition from the latter to the front and back, as shown in 1-24.

 

Figure 1-24 Creating a transition of two animation states

(3) Click the Start Game button in the Unity toolbar, and then view game and animator view, you will find that the sprite is playing the two animated states repeatedly, 1-25, but we are not yet able to specify which animation state to enter this article selected from Unity The development of the game from the beginner to proficient Tsinghua University Press .

Figure 1-25 Game and animator views

(4) To specify the animation state that the current sprite enters, you need to set the transition conditions for the two animation states. In the lower-left corner of the animator view, there is a small window named parameters, and you can add parameters by clicking the button to the right of it. In this example, you need to add a parameter of type bool named Walking, as shown in 1-26.

Figure 1-26 in the animator view, add a parameter of type bool

(5) Then in the Animator view, click the arrow that represents the transition from playeridleanimation to playerwalkinganimation in the animation state (the color of the arrows changes from white to blue), and then view the Inspector view, as shown in 1-27 , there is a conditions in the view below, it is used to set the condition of the animation transition, at this time the system set the animation transition condition is, after the animation played 1 seconds, into another animation state, so before we play the animation, the wizard has been in the two animation states jump.

Figure 1-27 Transition property settings for animation state in Inspector View

(6) Click Exit Time under Condition to select the parameter walking we just defined, and then set the property following it as shown in true,1-28. Indicates that the animation state transitions from playeridleanimation to playerwalkinganimation only if the parameter walking is true.

Figure 1-28 Setting transition conditions for animation state

In the same way, the transition condition from playerwalkinganimation to Playeridleanimation is walking, and its property is set to false, which means that the transition of the animation state occurs when walk is false.

(7) Run the game and look at the Games and animator View, 1-29. By default, walking has a value of false, so the game view has been playing the Playeridleanimator animation.

Figure 1-29 Game and animator views

Click the check box for the walking parameter under parameters in the lower-left corner of the animator view, which is set walking to true to view the animator view again, The sprite in the game view is now playing the Playerwalkinganimation animation, 1-30 as shown in this article selected from Unity 2D game development from beginner to proficient in Tsinghua University Press .

Figure 1-30 Game and animator views

Animator Windows View Project View Playeridleanimation and Playerwalkinganimation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.