Hi,i want the player do not run forever,but he gets “tired” of running.Well i just want to add Run Energy,Energy Regeneration to this sprint script,well once player get “tired” then after a while (some 6 seconds) hes got energy again and he can run,well i hope you understand what i said
So,can i have some help here? 
var NaturalSpeed = 10;
var tempSpeed : float;
var SpeedMultiplier = 1.2; // for 20% speed increase while sprinting
var moveDirection : Vector3; //this determines which direction we should be moving towards
var controller : CharacterController;
function Start() {
controller = GetComponent(CharacterController);
}
function Update()
{
moveDirection = Vector3.zero; //this rests our move direction to nothing so we wouldn't move unless movement keys were pressed
tempSpeed = NaturalSpeed; //this rests our speed back to natural speed
//this is just a simple movement check for demonstrating sprint; use your own methods of course
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
if(Input.GetKey(KeyCode.LeftShift)) //this checks to see if the player is holding left shift
{
moveDirection *= NaturalSpeed * SpeedMultiplier;
print("holding");
}
else {
moveDirection *= NaturalSpeed;
}
controller.Move(moveDirection * Time.deltaTime);
}
Here:
var NaturalSpeed = 10;
var tempSpeed : float;
var SpeedMultiplier = 1.2; // for 20% speed increase while sprinting
var energy = 6;
var canDrainEnergy = true;
var gainEnergy = true;
var moveDirection : Vector3; //this determines which direction we should be moving towards
var controller : CharacterController;
function Start() {
controller = GetComponent(CharacterController);
}
function Update()
{
moveDirection = Vector3.zero; //this rests our move direction to nothing so we wouldn't move unless movement keys were pressed
tempSpeed = NaturalSpeed; //this rests our speed back to natural speed
//this is just a simple movement check for demonstrating sprint; use your own methods of course
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
if(Input.GetKey(KeyCode.LeftShift) energy > 0) //this checks to see if the player is holding left shift
{
moveDirection *= NaturalSpeed * SpeedMultiplier;
if(canDrainEnergy)
{
DrainEnergy();
}[
print("holding");
}
else if(energy < 1)
{
if(gainEnergy)
{
GainEnergy();
}
}
else {
moveDirection *= NaturalSpeed;
}
controller.Move(moveDirection * Time.deltaTime);
}
function DrainEnergy ()
{
canDrainEnergy = false;
energy--;
yield WaitForSeconds (1F);
canDrainEnergy = true;
}
function GainEnergy ()
{
gainEnergy = false;
yield WaitForSeconds (6F);
energy = 6;
gainEnergy = true;
}
Need to go, see if you unsderstand else i check back later and explain!
WORKS MAN,you are AWESOME! Meybe you could help me at this question? :Action activates trigger. - Questions & Answers - Unity Discussions Anyway thanks for your help,and if you can then please help me at second question,thanks MAN,CHEERS! YOU ARE AWESOME 