how do i fix compil errors
Hello guys ! first, sorry about my english but i'm french ^^
So , i have many error :
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!
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.
i delete semicolon after condition, but errors stay :/
function OnCollisionEnter2D(coll:Collision2D){
if(coll.gameObject.tag == "Sol"){
ToucheSol=true;
}
}
function OnCollisionExit2D(coll:Collision2D){
if(coll.gameObject.tag == "Sol"){
ToucheSol=false;
}
}
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.
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;
}
}
@shuskry happy to help. Remember to Accept an answer once the problem is resolved.
Your answer

Follow this Question
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