var mainSpeed : float = 100.0; //regular speed var shiftAdd : float = 250000.0; //multiplied by how long shift is held. Basically running var maxShift : float = 1000000000.0; //Maximum speed when holdin gshift var camSens : float = 0.25; //How sensitive it with mouse private var totalRun : float = 1.0; function Start (){ Cursor.visible = true; } function Update () { var f : float = 0.0; var p = GetBaseInput(); if (Input.GetKey (KeyCode.LeftShift)){ totalRun += Time.deltaTime; p = p * totalRun * shiftAdd; p.x = Mathf.Clamp(p.x, -maxShift, maxShift); p.y = Mathf.Clamp(p.y, -maxShift, maxShift); } p = p * Time.deltaTime; if (Input.GetKey(KeyCode.Space)){ f = transform.position.y; transform.Translate(p); transform.position.y = f; } else{ transform.Translate( p); } } private function GetBaseInput() : Vector3 { var p_Velocity : Vector3; if (Input.GetKey (KeyCode.W)){ p_Velocity += Vector3(0, 4 ); } if (Input.GetKey (KeyCode.S)){ p_Velocity += Vector3(0, -4 ); } return p_Velocity; }
if (Input.GetAxis("Mouse ScrollWheel") > 0)
p_Velocity +=Vector3(0,4);
else
p_Velocity -=Vector3(0,-4);