the code works fine and all but im trying 2 add a auto run into it but im not sure what i need 2 add into the code to allow it
var speed : float = 6.0;
var increase = 0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
var script : speed;
var autorun : boolean = false;
private var moveDirection : Vector3 = Vector3.zero;
function Update()
{
script = this.GetComponent("speed");
speed = script.speed;
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
if (Input.GetKey(KeyCode.LeftShift))
{
if (Input.GetKey(KeyCode.W))
{
autorun = !autorun;
}
}
if(autorun)
{
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}