- Home /
Getting several BCE0044 compiler errors for OnCollisionEnter. Is my syntax wrong?
Below is the problematic UnityScript that I have attempted to isolate:
var isCollideTurning : boolean; function FixedUpdate () {
function OnCollisionEnter (){
isCollideTurning = true;
}
}
Even when I compiled it in an empty project, specially created for testing, I still get the following errors:
Script.js(7,34): BCE0044: expecting :, found '='.
Script.js(6,18): BCE0044: expecting (, found 'OnCollisionEnter'.
Script.js(6,37): UCE0001: ';' expected. Insert a semicolon at the end.
I have only been coding in UnityScript for under a week, and have no prior coding experience so I am not sure if I have simply made a glaring syntax error.
Could someone tell me what I am doing wrong?
Answer by ShadowBroker · Apr 28, 2011 at 06:59 PM
Don't ever put a function into a function! That means, no OnCollisionEnter in FixedUpdate. Just write:
var isCollideTurning : boolean;
function FixedUpdate () {
}
function OnCollisionEnter (){ isCollideTurning = true; }
In this example, FixedUpdate doesn't contain anything so you can remove it simply if you want. So, everything you need is this:
var isCollideTurning : boolean;
function OnCollisionEnter (){ isCollideTurning = true; }
Answer by flaviusxvii · Apr 28, 2011 at 06:59 PM
You can't declare a function in a function you maniac.
Answer by FLASHDENMARK · Apr 28, 2011 at 06:58 PM
You cant have a function inside another function(as far as i am aware!).
Answer by StephanK · Apr 28, 2011 at 06:58 PM
You are declaring a function within a function. That is not possible. Move the inner function OnCollisionEnter outside of the brackets of the FixedUpdate function.