1: Create a Sprite Render (player) Animation object and add the script player, click the main Menu "window" →animation (animation window) Animation panel (select the object you want to animate) Click Create animation (named Idle) to save to a custom folder (Animation)
Select Add Sprite in 2:addproperty
3: Drag the Sprite to the appropriate frame position in the specified order. You can change the playback rate by samples
4: Add animations for various states (Create New Clip) such as: Run,jump,down
5: Open the animator, which contains all the animated states previously added
Any state, which is a pointer to an animation, can be toggled as long as the condition satisfies any status, such as Death animation.
Entry the animation to play in the starting state.
6: Add status Switch condition (Float,int,bool,trigger)
Example: You can add a variable named Isrun of type bool
7: Transitions between various animations (make Transition)
The idle state points to a transition in the run state
8: Click the arrow, the idle state can switch to the run state, you can add the status switch condition in the lower right corner isrun
9: When Isrun is true, switch from state idle to state run when Isrun is false by state run switch to state idle.
10: After the animation is set up, the animation can be toggled with simple script control
Note: Loop playback issues When you encounter any state jump status. The root cause is that any state contains its own status resulting in the jump status->jump state, so it loops when the condition is met. Cancel the can Transition to tick option.
Unity Simple Animation Implementation