what is EOF, found 'else' PLEASE HELP!!
var currentHealth : float = 100; var maxHealth : int = 100;
var currentStamina : float = 100.0; var maxStamina : int = 100;
var barLength = 0.0;
private var chMotor : CharacterJoint;
function Start() { barLength = Screen.width / 8; chMotor = GetComponent(CharacterJoint); }
function Update () { AdjustCurrentHealth (0);
//Stamina control
var controller : CharacterController = GetComponent(CharacterController);
//pressing shift for speed
if (controller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift)
)
currentStamina -= Time.deltaTime * 10;
chMotor.movement.maxFowardSpeed = 10;
chMotor.movement.maxSidewaySpeed = 10;
}
//not pressing anything
else
{
chMotor.movement.maxFowardSpeed = 6;
chMotor.movement.maxSidewaySpeed = 6;
}
//cant move when stamina is 0
if(controller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift) && currentStamina <= 0)
{
chMotor.movement.maxFowardSpeed = 6;
chMotor.movement.maxSidewaySpeed = 6;
}
//Stamina regeneration
if(controller.velocity.magnitude == 0 && (currentStamina >= 0))
{
currentStamina += Time.deltaTime * 2;
}
// if stamina is max never go past
if(currentStamina >= maxStamina)
{
currentStamina = maxStamina;
}
if(currentStamina <= 0)
{
currentStamina = 0;
}
}
function OnGUI () { //Icons for GUI GUI.Box(new Rect (5, 30, 50, 20), "Health"); GUI.Box(new Rect (5, 60, 60, 20), "Stamina");
//Health / Stamina main bars
GUI.Box (new Rect(60, 30, barLength, 20), currentHealth.ToString("0") + "/" + maxHealth);
GUI.Box (new Rect(70, 60, barLength, 20), currentStamina.ToString("0") + "/" + maxStamina);
}
function AdjustCurrentHealth (adj) { currentHealth += adj;
if(currentHealth >= maxHealth)
{
currentHealth = maxHealth;
}
if(currentHealth <= 0)
{
currentHealth = 0;
}
}
Do a google search for EOF. Or try "computer program EOF" or "C# EOF".
Also, see if you can find something about how to find and fix errors, and how to read the messages. I think several people have written things like that for Unity. They aren't as good as going through a regular Intro to Computer Program$$anonymous$$g book, but they're good enough.
Answer by Positive7 · Jan 16, 2016 at 07:21 PM
Because you missing a {
after if (controller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift))
if (controller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift))
{