Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by JimRoot · Nov 15, 2013 at 07:01 PM · javascripterroreof

expecting EOF, found 'else'.

Hey folks!

I'am having a problem with the following script:

 var car : Transform;
 var player : Transform;
 var exitPoint : Transform;
 var doorTriggerLeft : Transform;
 var isPlayerVisible : boolean;
 
 
 function Update()
 {
 var screenRay : Ray= Camera.main.ScreenPointToRay(Input.mousePosition);
 var rayhit : RaycastHit;
 if(Physics.Raycast(screenRay,  rayhit));
 if(rayhit.collider.tag == "doorTriggerLeft");
 }
 Debug.Log("Driving");
 {
 player.gameObject.SetActiveRecursively(false);
 player.gameObject.active = false;
 player.parent = exitPoint.transform;
 player.transform.localPosition = Vector3(-1.5,0,0);
 
 exitPoint.parent = car.transform;
 exitPoint.transform.localPosition = Vector3(-0.3,1.5,-0.65);
 
 GameObject.Find("Car").GetComponent("CarControl").enabled=true;
 
 }
 else
 {
 if (Input.GetKeyUp("r")) 
 {
 Debug.Log("Walking");
 
 player.gameObject.SetActiveRecursively(true);
 player.gameObject.active = true;
 
 player.transform.parent = null;
 
 exitPoint.parent = car.transform;
 GameObject.Find("Car").GetComponent("CarControl").enabled=false;
 }
 }
 }
 
 function OnTriggerEnter(Player : Collider)
 {
 Debug.Log("Trigger Enter");
 isPlayerVisible = true;
 }
 
 function OnTriggerExit(Player : Collider)
 {
 Debug.Log("Trigger Exit");
 isPlayerVisible = false;
 }

unity gives me the following error:

 Assets/Standard Assets/Scripts/Car entering & exiting.js(28,1): BCE0044: expecting EOF, found 'else'.

could you maybe help me with that and show me where i can find the error? i know EOF means end of field and usually he excepting or missing a { or } but in my opinion everything is right :/

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Nov 15, 2013 at 07:14 PM

You should really indent code properly so you can see where the incorrect { } are. Also you're putting ; after if statements, which is wrong. If statements work like this:

 if (something) {
    do something else
 }
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
avatar image
0

Answer by cmpgk1024 · Nov 15, 2013 at 07:13 PM

You are missing a } at the end, to match the opening brace after function Update(){.

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.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is an EOF error and how can i fix the problem? 1 Answer

Unexpected token: targetPos 1 Answer

Hi I get an error code when i'm using my Javascript and I can't understand how to fix it... :( 1 Answer

expecting EOF, found 'showOptions' 1 Answer

Why doesnt my script work 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges