- Home /
 
what is the problem of this code ?
hello , I write a code with new function but when save it this errors show up :
 BCE0044: expecting (, found 'Action_Pass_1'.
 
 UCE0001: ';' expected. Insert a semicolon at the
 
 BCE0043: Unexpected token: if.
 
 UCE0001: ';' expected. Insert a semicolon at the
 
 BCE0044: expecting :, found ';'.
 
               my code is this :
     if( Pass_1 ){
         Action_Pass_1();
                 }    
                       }
                       
                       
                       
 //========= Actions function ==============//      
                 
 function Action_Pass_1(){
 
     if(Stage == false){
 
       transform.Translate(0,0,Speed*Time.deltaTime);
                      }
     if(Mathf.Abs(transform.position.z-SecoundPosition.z)< 0.1){
     
     Stage = true;
                                                               }
 
               thanks
you have a bracket too in the first if. and missing one in the last if;
Answer by killer-zog · Jun 28, 2013 at 07:45 AM
here is the modified code. i modified this with the commented code,
 function Update () {
     // up
     if( direction == 1 )
     {
     x = 0;
     y = 0;
     z = force;
     }
     // down
     if( direction == 2 )
     {
     x = 0;
     y = 0;
     z = -force;
     }
     // left
     if( direction == 3 )
     {
     x = -force;
     y = 0;
     z = 0;
     }
     // right
     if( direction == 4 )
     {
     x = force;
     y = 0;
     z = 0;
     }
     // u-l
     if( direction == 5 )
     {
     x = -force;
     y = 0;
     z = force;
     }
     //u-r
     if( direction == 6 )
     {
     x = -force;
     y = 0;
     z = -force;
     }
     //d-l
     if( direction == 7 )
     {
     x = force;
     y = 0;
     z = force;
     }
     //d-r
     if( direction == 8 )
     {
     x = force;
     y = 0;
     z = -force;
     }
     // if player allow to shoot determine direction of it.
  
     if(can_shoot){
  
     // right shoot
  
     if(direction == 4)
     {
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
  
     Shoot_1();
     direction = 0;
     }
     // left shoot
     if(direction == 3){
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
  
     Shoot_2();
     direction = 0;
     }
     }
     // if player allow to pass determine direction of it .
     if(can_pass){
     // right pass
     if(direction == 4)
     {
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
  
     Pass_1();
     direction = 0;
     }
     // left pass
     if(direction == 3){
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
  
     Pass_2();
     direction = 0;
     }
     // up pass
     if( direction == 1){
     Pass_left();
     direction = 0;
     }
     // down pass
     if( direction == 2){
     Pass_right();
     direction = 0;
     }
  
 }
 //**************************************************************************
 //             test
 //***************************************************************************   
     if( Input.GetKeyDown(KeyCode.H)){
  
     FirstPosition = gameObject.transform.position;
  
     SecoundPosition.x = FirstPosition.x;
  
     SecoundPosition.y = FirstPosition.y;
  
     SecoundPosition.z = FirstPosition.z + Distance;
  
     }
     if(Input.GetKeyUp(KeyCode.H)){
        if(Pass_1){     
       Pass_1 = false;
            }
        if(!Pass_1){      
       Pass_1 = true;
             }
  
     }
 //************************************************************
 //*************************************************************
  
     if( Pass_1 ){
        Action_Pass_1();
           }   
               }
  
  
  
 //========= Actions function ==============//   
  
 function Action_Pass_1(){
  
     if(Stage == false){
  
     transform.Translate(0,0,Speed*Time.deltaTime);
                }
     if(Mathf.Abs(transform.position.z-SecoundPosition.z)< 0.1){
  
     Stage = true;
                                          }
     if(Stage == true){
  
     transform.Translate(0,0,-Speed*Time.deltaTime);
  
     if(Mathf.Abs(transform.position.z-FirstPosition.z)< 0.1){
  
     Pass_1 = false;
     Stage = false;
                                          }
                                          }
  
  
 }
 
 
              First thank from your helps ; I Search the forgoted bracket but can't find any one in this functions:
 function Update () {
     // up
     if( direction == 1 )
     {
     x = 0;
     y = 0;
     z = force;
     }
     // down
     if( direction == 2 )
     {
     x = 0;
     y = 0;
     z = -force;
     
     // left
     if( direction == 3 )
     {
     x = -force;
     y = 0;
     z = 0;
     }
     // right
     if( direction == 4 )
     {
     x = force;
     y = 0;
     z = 0;
     }
     // u-l
     if( direction == 5 )
     {
     x = -force;
     y = 0;
     z = force;
     }
     //u-r
     if( direction == 6 )
     {
     x = -force;
     y = 0;
     z = -force;
     }
     //d-l
     if( direction == 7 )
     {
     x = force;
     y = 0;
     z = force;
     }
     //d-r
     if( direction == 8 )
     {
     x = force;
     y = 0;
     z = -force;
     }
     // if player allow to shoot deter$$anonymous$$e direction of it.
     
     if(can_shoot){
     
     // right shoot
     
     if(direction == 4)
     {
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
     
     Shoot_1();
     direction = 0;
     }
     // left shoot
     if(direction == 3){
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
     
     Shoot_2();
     direction = 0;
     }
     }
     // if player allow to pass deter$$anonymous$$e direction of it .
     if(can_pass){
     // right pass
     if(direction == 4)
     {
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
     
     Pass_1();
     direction = 0;
     }
     // left pass
     if(direction == 3){
     FirstPosition = gameObject.transform.position;
     SecoundPosition.z = FirstPosition.z + Distance;
     
     Pass_2();
     direction = 0;
     }
     // up pass
     if( direction == 1){
     Pass_left();
     direction = 0;
     }
     // down pass
     if( direction == 2){
     Pass_right();
     direction = 0;
     }
 
 }    
 //**************************************************************************
 //                        test
 //***************************************************************************    
     if( Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.H)){
     
     FirstPosition = gameObject.transform.position;
     
     SecoundPosition.x = FirstPosition.x;
     
     SecoundPosition.y = FirstPosition.y;
      
      SecoundPosition.z = FirstPosition.z + Distance;
     
     }
     if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.H)){
         if(Pass_1){        
          Pass_1 = false;
                  }
         if(!Pass_1){         
          Pass_1 = true;
                   }
                           
      }
 //************************************************************
 //*************************************************************
     
     if( Pass_1 ){
         Action_Pass_1();
                 }    
                       }
                       
                       
                       
 //========= Actions function ==============//      
                 
 function Action_Pass_1(){
 
     if(Stage == false){
 
       transform.Translate(0,0,Speed*Time.deltaTime);
                      }
     if($$anonymous$$athf.Abs(transform.position.z-SecoundPosition.z)< 0.1){
     
     Stage = true;
                                                               }
     if(Stage == true){
     
     transform.Translate(0,0,-Speed*Time.deltaTime);
     
     if($$anonymous$$athf.Abs(transform.position.z-FirstPosition.z)< 0.1){
     
     Pass_1 = false;
     Stage = false;
                                                               }
                                                               }
                     
 
 }
 
                 and for bracket problems, when you write codes first, close the bracket and then put codes in them, this way you will have less errors. :)
Answer by Eugenius · Jun 28, 2013 at 07:32 AM
Well, the first error probably refers to the previous function that's missing a curly bracket somewhere.
Also at the end of the Action_Pass_1 function you need to add one more curly bracket as you haven't closed the function yet (from what's visible in the code provided).
Your answer
 
             Follow this Question
Related Questions
Trying to get score counter... 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
unknown identifer explosion problem 2 Answers