3D movement, after binding the humanoid controller
usingUnityengine;usingSystem.Collections; Public classPlayermove:monobehaviour {PrivateCharactercontroller cc; PrivateAnimator Animator; Public floatSpeed =4; voidAwake () {cc= This. Getcomponent < charactercontroller>(); Animator= This. Getcomponent<animator>(); } //Update is called once per frame voidUpdate () {floatH = Input.getaxis ("Horizontal"); floatv = Input.getaxis ("Vertical"); //The value of the key to take precedence over the value in the virtual bar if(Joystick.h! =0|| JOYSTICK.V! =0) {h=Joystick.h; V=joystick.v; } if(Mathf.abs (h) >0.1f|| Mathf.abs (v) >0.1) {animator. Setbool ("Walk",true); if(Animator. Getcurrentanimatorstateinfo (0). Isname ("Playerrun") {Vector3 TargetDir=NewVector3 (H,0, V); Transform. LookAt (TargetDir+transform.position); Cc. Simplemove (Transform.forward*Speed ); } } Else{animator. Setbool ("Walk",false); } }}
Unity3d 3D Game Sports