Similar to the game of DotA mobile method, the rest is nothing to say.
usingUnityengine;usingSystem.Collections; Public classGogogogo:monobehaviour { Public floatMovespeed; PublicVector3 newposition; PublicCharactercontroller Charactercontroller; //Public Animationclip Idle; //Public Animationclip Run; //Use this for initialization voidStart () {newposition=transform.position; } //Update is called once per frame voidUpdate () {if(Input.getmousebutton (0) ) {locateposition (); } movetoposition (); } //a way to get a click on the mouse click position voidlocateposition () {Raycasthit hit; Ray Ray .=Camera.main.ScreenPointToRay (input.mouseposition); if(Physics.raycast (Ray, outHit +)) { if(Hit.collider.tag! ="Player") {newposition=NewVector3 (HIT.POINT.X,HIT.POINT.Y,HIT.POINT.Z); } } } //a way to start moving and rotate voidmovetoposition () {if(Vector3.distance (transform.position,newposition) >2){ //Rotatequaternion newrotation = quaternion.lookrotation (Newposition-transform.position, Vector3.forward); Newrotation.x=0f; Newrotation.z=0f; Transform.rotation= Quaternion.slerp (Transform.rotation, Newrotation, time.deltatime* -); //MovingCharactercontroller. Simplemove (Transform.forward *movespeed); //Animation. Crossfade (run.name); } Else { //Animation. Crossfade (idle.name); } }}
The moving of the role of Unity3d--the mouse movement under the view angle