Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by shuskry · Oct 13, 2015 at 04:02 PM · errorscript.compile

how do i fix compil errors

Hello guys ! first, sorry about my english but i'm french ^^

So , i have many error : alt text

And this is my script :

function OnCollisionEnter2D(coll:Collision2D){

 if(coll.gameObject.tag == "Sol");{
 ToucheSol=true;
 }

}

function OnCollisionExit2D(coll:Collision2D){

 if(coll.gameObject.tag == "Sol");{
 ToucheSol=false;
 }

}

So , if someone can save me u.u !! Thx a lot!

eroor.png (12.4 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Dave-Carlile · Oct 13, 2015 at 04:23 PM

The way to code an if statement is this:

 if (condition)     // <-- semicolon does *not* go here
 {
 }

There is no semicolon after the condition, which is what you have in yours.

Comment
Add comment · Show 6 · 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 shuskry · Oct 13, 2015 at 05:49 PM 0
Share

i delete semicolon after condition, but errors stay :/

alt text

function OnCollisionEnter2D(coll:Collision2D){

 if(coll.gameObject.tag == "Sol"){
 ToucheSol=true;
 }

}

function OnCollisionExit2D(coll:Collision2D){

 if(coll.gameObject.tag == "Sol"){
 ToucheSol=false;
 }

}

eroor.png (25.2 kB)
avatar image Dave-Carlile shuskry · Oct 13, 2015 at 05:56 PM 0
Share
  • Please use comments for discussion, not Answers. I converted your Answer to a Comment.

  • Please use the 101010 button on your code in order to format it so it's more readable.

The code you showed now looks okay. Sometimes missing ; and ( type errors are actually a symptom of a different error somewhere else because the compiler doesn't understand what you're trying to do. Can you post the entire class? Or at least everything from the beginning to the end of OnCollisionExit2D.

And when you do so, please use the 101010 button to format your code.

avatar image shuskry Dave-Carlile · Oct 13, 2015 at 06:21 PM 0
Share

Sorry about that ^^, thanks for your help !

this is my script :

 #pragma strict
 
 var ToucheSol:boolean=false;
 
 function Start () {
 
 }
 
 function Update () {
     
     transform.rotation.x =0;
     transform.rotation.y =0;
     transform.rotation.z =0;
     
     if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space) && ToucheSol == true){
     
     rigidbody2D.AddForce(Vector2(0,2000));
     
     
 
 }
 
 function OnCollisionEnter2D(coll:Collision2D){
 
     if(coll.gameObject.tag == "Sol"){
     ToucheSol=true;
     }
 }
 
 function OnCollisionExit2D(coll:Collision2D){
 
     if(coll.gameObject.tag == "Sol"){
     ToucheSol=false;
     }
 }

Show more comments
Show more comments
avatar image Dave-Carlile · Oct 13, 2015 at 08:53 PM 0
Share

@shuskry happy to help. Remember to Accept an answer once the problem is resolved.

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

33 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 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

How to fix a compiler error? 2 Answers

Can't Add Script Behavior... 2 Answers

how do i resolve this problem? 0 Answers

Game Does Not Work Properly 0 Answers

can't add script behaviour TMP_SelectionCaret . The script need to derive from MonoBehaviour 4 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