1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class MoveCharacters : MonoBehaviour {
public int Speed;
public int Sensivity;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (isLocalPlayer) {
float MovZ = Input.GetAxis ("Vertical") * Time.deltaTime;
MovZ *= Speed;
float MovX = Input.GetAxis ("Horizontal") * Time.deltaTime;
MovX *= Speed;
if (MovZ > 0) {
GetComponent<Animator> ().SetBool ("Foward", true);
GetComponent<Animator> ().SetBool ("Back", false);
} else if (MovZ < 0) {
GetComponent<Animator> ().SetBool ("Foward", false);
GetComponent<Animator> ().SetBool ("Back", true);
} else {
GetComponent<Animator> ().SetBool ("Foward", false);
GetComponent<Animator> ().SetBool ("Back", false);
}
if (MovX < 0) {
GetComponent<Animator> ().SetBool ("Left", true);
GetComponent<Animator> ().SetBool ("Right", false);
} else if (MovX > 0) {
GetComponent<Animator> ().SetBool ("Left", false);
GetComponent<Animator> ().SetBool ("Right", true);
} else {
GetComponent<Animator> ().SetBool ("Left", false);
GetComponent<Animator> ().SetBool ("Right", false);
}
this.transform.Translate (new Vector3 (MovX, 0, MovZ));
this.transform.Rotate (new Vector3 (0, Input.GetAxis ("Mouse X") * Sensivity, 0));
GetComponentInChildren <PointCamera> ().transform.Rotate (-new Vector3 (Input.GetAxis ("Mouse Y") * Sensivity, 0, 0));
}
}
} |
Partager