Today we have studied the next animation state opportunity to a problem. There is an animation I just want to play with him once, but in some circumstances I need to let him play again.
There are probably two ways to do this:
1. Use Animatior Parameters that's usually the case.
2. Create a statemachinebehaviour for the animation node, which has a life cycle when the animation is finished, in which you can determine whether to jump or continue to play repeatedly
Let's look at the life cycle of Statemachinebehaviour:
usingUnityengine;usingSystem.Collections; Public classD:statemachinebehaviour {//for the time being, just list some of these common//when the animation enters play Public Override voidOnstateenter (Animator Animator, Animatorstateinfo StateInfo,intLayerindex) { Base. Onstateenter (animator, StateInfo, Layerindex); } //when the animation has finished playing Public Override voidOnstateexit (Animator Animator, Animatorstateinfo StateInfo,intLayerindex) { Base. Onstateexit (animator, StateInfo, Layerindex); } //Refresh animation every frame call Public Override voidOnstateupdate (Animator Animator, Animatorstateinfo StateInfo,intLayerindex) { Base. Onstateupdate (animator, StateInfo, Layerindex); } }
Unity Statemachinebehaviour life cycle