Using Unityengine;
Using System.Collections;
Using Assets.model;
public class Playermove:monobehaviour {
Use this for initialization
Private Playeranimation m_scriptplayeranimation;
public int playermovespeed;
Private Unityengine.vector3 Movedistancex, Movedistancey;
Private Charactercontroller M_charactercontroller;
Private Unityengine.vector3 targetpostion;
public int m_state;
Private Movedto senddto;
private string Sendstr;
void Start () {
M_scriptplayeranimation = this. Getcomponent<playeranimation> ();
Senddto = new Movedto ();
Senddto.name = Gameinfo.getinstance (). Myheromodel.name;
Senddto.map = Gameinfo.getinstance (). Myheromodel.map;
M_state = Playerstate.idle;
Playermovespeed = 6;
M_charactercontroller = this. Getcomponent<charactercontroller> ();
if (Gameobject.name = = "Jiansheng (Clone)")
Playermovespeed =-playermovespeed;
}
Update is called once per frame
void Update () {
Movedistancex = transform.right * playermovespeed * Input.getaxis ("horizontal");
Movedistancey = Transform.forward * playermovespeed * Input.getaxis ("Vertical");
if (Movedistancex + Movedistancey = = UnityEngine.Vector3.zero)
M_scriptplayeranimation.mystate = Playerstate.idle;
Else
{
M_charactercontroller.simplemove (Movedistancex + Movedistancey);
M_scriptplayeranimation.mystate = Playerstate.move;
Send your own location, status information to the server
Senddto.point = new Assets.Model.Vector3 (transform.position);
Senddto.rotation = new Assets.Model.Vector4 (transform.rotation);
Senddto.dir = Playerstate.move;
Sendstr = Coding<movedto>.encode (senddto);
Networkscript.getinstance (). SendMessage (Protocol.map, 0, Mapprotocol.move_creq, SENDSTR);
}
/* IF (Input.getaxis ("Fire1") >0)
M_state = Playerstates.attack1;
else if (Input.getaxis ("Fire2") > 0)
M_state = Playerstates.attack2;
else if (Input.getaxis ("Fire3") > 0)
M_state = playerstates.skill;*/
}
}
Keyboard control character Movement