- Home /
 
 
               Question by 
               Angel Of Death · Nov 12, 2012 at 02:48 AM · 
                bce0044uce0001  
              
 
              Three errors in my project, PLEASE HELP!
This is the code for my project #pragma strict
 function Start () {
 
 }
 
 function Update () {
 function OnTriggerEnter(){
     gameObject.light.enabled = false;
     
 }
 function OnTriggerExit(){
     gameObject.light.enabled = true;
     
 }
 }
 these are the errors in my code
 
 Assets/light.js(8,10): BCE0044: expecting (, found 'OnTriggerEnter'.
 
 Assets/light.js(8,26): UCE0001: ';' expected. Insert a semicolon at the end.
 
 Assets/light.js(9,34): BCE0044: expecting :, found '='.
 
 
              
               Comment
              
 
               
              Check your file name, whether it is .js or .cs...$$anonymous$$anytime this cause the problem...
Answer by BeHappy · Nov 12, 2012 at 05:14 AM
You should write Functions outside Update. You are writing functions, OnTriggerEnter and OnTriggerExit inside the function update....
It should be like this,
 function Start () 
 {
 
 }
 
 function Update () 
 {
 
 }
 
 function OnTriggerEnter(){
     gameObject.light.enabled = false;
 
 }
 
 function OnTriggerExit(){
     gameObject.light.enabled = true;
 }
 
              BeHappy nailed it. Plus, make sure that his code is on your object with the collider OR player and that the gameObjects are set accordingly.
Your answer
 
             Follow this Question
Related Questions
BCE0044 error 0 Answers
Javascript Expecting Errors ';' & '=' 0 Answers
Error BCE0044 && UCE0001 1 Answer
scripting colliders errors 1 Answer