Simple Sprint?

How would I make my fps controller go from the speed of 10 to about 12 and play a sprint animation on my gun when shift is held down? I have looked around for an answer to this but nothing came up that worked, can anyone help me out please?

else if(Input.GetKey(“up”))

function Sprint(){
  transform.position.x +=12;}
function Walk(){


The first if checks first if sprint button is down, so that if not it jumps right on to the else if (you save some cycles this way) and then walk, if s is down then it checks if up is down(…)and then does the sprint function and the sprint animation.

The function are simplified, they could/should include all directions instead.

If you’re using the First Person Controller prefab, you can find here a script to make it run and crouch. If you’re using a custom movement script, however, you should modify the speed when the key is pressed - something like this:

var regSpeed: float = 10.0;
var sprintSpeed: float = 12.0;

function Update(){
  var speed = regSpeed;
  if (Input.GetKey("left shift") || Input.GetKey("right shift")){
    speed = sprintSpeed;
  character.Move(moveDir * speed * Time.deltaTime);

About the animations: you can have an sprint animation and crossfade to it when shift is pressed. Another alternative is to create a hard coded animation, but the result usually is too artificial.