• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by dmanbalji · Jan 16, 2016 at 06:52 PM · elseeof

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;
     }

}

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gjf · Jan 15, 2016 at 08:18 PM 0
Share

please format ALL of your code...

avatar image Owen-Reynolds · Jan 16, 2016 at 06:54 PM 0
Share

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 Programming book, but they're good enough.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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))
 {
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

expecting } found Else and expecting EOF found } ??? 1 Answer

Error Expecting EOF found ';' HELP 2 Answers

How would you shorten that piece of code? 3 Answers

If statement being ignored 2 Answers

expecting EOF, found 'else'... WHat is this??!! 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges