is there a better way to do this movement script?

hi everyone,

I’ve made this movement script that’s attached to my player. It controls the player walking, running with a resource that decreases when the run button (left shift) is pressed, regenerates the resource when not running and has a regeneration ‘delay’ when the resource is fully depleted. The code is working as I’d like, I’m just worried that i may be taking the long way around on this and that there is a more efficient way to do this (less lines of code is better right?).

Here is my code

#pragma strict

	var playerSpeed : float = 10.0;
	var playerWalkSpeed : float = 10.0;
	var playerRunSpeed : float = 50.0;
	var playerRunPower : float = 50.0;
	var playerRunPowerMax : float = 50.0;
	var playerRunPowerDecrease : float = 1.0;
	var playerRunPowerIncrease : float = 1.0;
	var playerRunWait : float = 5.0;
	var playerRunWaitIncrease : float = 1.0;
	var playerRunBuffer : float = 5.0;

	
	private var player :CharacterController;
	player = gameObject.GetComponent(CharacterController);


function Update(){

	if(Input.GetKey(KeyCode.LeftShift) && playerRunPower > 0 && playerRunWait >= 5 && player.velocity.magnitude > 0){
			if(Input.GetAxis ("Vertical") || Input.GetAxis ("Horizontal")){
				playerSpeed = playerRunSpeed;
				playerRunPower -= playerRunPowerDecrease * Time.deltaTime;
			}
		}
		else{
			
			playerSpeed = playerWalkSpeed;
				
				if(playerRunPower < 1){
				playerRunWait = 0;
				}
				
				if(playerRunWait < playerRunBuffer){
				
				playerRunWait += playerRunWaitIncrease * Time.deltaTime;
				
				}
				
				if(playerRunPower < playerRunPowerMax){
				
				playerRunPower += playerRunPowerIncrease * Time.deltaTime;
				
				}
			}
	}


function FixedUpdate(){
	
	var movement = Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")) * Time.deltaTime * playerSpeed;
	
	player.Move(movement);
		
}

@script RequireComponent(CharacterController)

DONT EVEN BOTHER THINKING ABOUT IT!
there may be a better way, but you say it works fine as want ti. Do not spend another minute thinking about.
When game is getting closer to finish, and if you have performance issues. Start to track what is slow. I can promise you that it will not be this code.

Early over-optimizing is a disease that will prevent you Finnish any game