usingUnityengine;usingSystem.Collections; Public classPlayeranimation:monobehaviour {floatver; PrivateAnimator ANI; voidAwake () {ANI= getcomponent<animator> (); } voidUpdate () {ver= Input.getaxis ("Vertical"); //set animation state machine Parameters//ANI. Setinteger ("number", (int) mathf.abs (ver));Ani. Setinteger (HashIDs.instance.Number, (int) Mathf.abs (ver)); //Front key, character facing forward, rear key, character facing back if(Ver >0) {Transform.eulerangles=Vector3.zero; } Else if(Ver <0) {Transform.eulerangles= Vector3.up * the; } //Press the space and the player shouts if(Input.getkeydown (keycode.space)) {ani. Settrigger ("Shout"); } }}
The above script mounts the characters to achieve the effect of controlling task execution animation.
The next step is to set the animation's speed assignment
usingUnityengine;usingSystem.Collections; Public classHashids:monobehaviour { Public StaticHashids instance; voidAwake () {instance= This; } Public intSpeed ; Public intNumber ; Public intIdle; Public intRun; voidStart () { speed= Animator.stringtohash (" Speed"); number= Animator.stringtohash (" Number"); Idle= Animator.stringtohash ("Idle"); Run= Animator.stringtohash ("Run"); }}
Demon_ animation control (to move around before and after the implementation, shouting)