Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by alone1992 · Jun 28, 2013 at 07:01 AM · function

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

Comment
Add comment · Show 1
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 moha · Jun 28, 2013 at 07:33 AM 1
Share

you have a bracket too in the first if. and missing one in the last if;

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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;
                                          }
                                          }
  
  
 }

 
Comment
Add comment · Show 5 · 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 alone1992 · Jun 28, 2013 at 08:50 AM 0
Share

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;
                                                               }
                                                               }
                     
 
 }
avatar image killer-zog · Jun 28, 2013 at 09:01 AM 1
Share

okay i fixed the code above. hope this works.

avatar image killer-zog · Jun 28, 2013 at 09:02 AM 1
Share

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. :)

avatar image alone1992 · Jun 28, 2013 at 09:12 AM 0
Share

thanks a lot dear , It solved

avatar image killer-zog · Jun 28, 2013 at 09:18 AM 1
Share

you welcome, glad to help.

avatar image
1

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).

Comment
Add comment · Show 1 · 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 alone1992 · Jun 28, 2013 at 09:12 AM 1
Share

thanks a lot dear friend

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

18 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

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

problem with my simple script please help. 2 Answers

Yield function goes slow sometimes/differently? 2 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