Import the character model, the model is not moving, because no animation is added
First add the animator component to the model
Some models have their own components, because we set him up as a human animation, if it is normal animation to add their own. After adding the components, we found that a animator controller (animation controller) was missing, and we needed to add a drag in. Add an animated clip inside the controller. Click into the animator view to find the idle animation in the file and drag it in. The orange color is the default animation. Then drag into an attack animation atrrack, right key make Transition (create transition), at this time will find the animation automatically play, if we do not want to let the animation automatically transition, we need to add a condition to the transition, click on the Transition line, the tab has a transition condition
But now the transition condition is empty, so we have to create a transition condition ourselves, back to the parameters option on the left, we add a triggerr (trigger) condition to it and set it in conditions. Now attack is a one-time action, will not repeat, so this action will stop after playing, so we want to let Attackk back to idle state. Even back. We will find that when you click Trigger, you will not immediately jump from the idle state to the Atrrack state, which is because we have selected the default check has Exit time
If this button is checked, the animation will play the default playback of the next animation, if not checked, it will immediately play.
Use code to control the character attack trigger conditions. Add a C # script to the character.
Add a character run animation and code control (run animation), because running is a continuous action, when I hold the W, he should continue running, so we want to set a bool type of conditions. Run and stop are to be completed immediately, so should not be checked has exiit time. Code implementation