Code:
var speed : float; var rotationSpeed : float = 100.0; function Update () { var forward : Vector3 = Camera.main.transform.TransformDirection(Vector3.forward); var right : Vector3 = Camera.main.transform.TransformDirection(Vector3.right); var controller : CharacterController = GetComponent(CharacterController); var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed; if (Input.GetAxis("Vertical")) { controller.Move(forward * speed); // 7 is depending the value you want to give for speed.. } if (Input.GetAxis("Horizontal")) { controller.Move(right * speed); } transform.Rotate(forward); }
Comment