Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by DogPoo74 · Apr 14, 2016 at 12:27 PM · scripting problem

An other why “; expected. Insert a semicolon at the end“ sorry,

Hi, i know it is a frequently asked question, but i am a lost beginner. I have this (22,13): UCE0001: ';' expected. Insert a semicolon at the end. and i don't understand, i have already a semicolon on this line.

 #pragma strict
 
 var animator : Animator;
 animator.SetBool("Punching", false);
 
 function Start () 
    {
    animator = this.GetComponent(Animator);
    }
 
 function Update () 
    {
 
    if (Input.GetKeyDown(KeyCode.G)) 
       {
        animator.SetBool("Punching", true);
        StartCoroutine("StopAnimation");
       }
 
    IEnumerator StopAnimation()
       {
        yield return new WaitForSeconds(0.5);
        anim.SetBool("Punching", false);
       }
 
    }



Can you help me please, thanks in advance!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Immanuel-Scholz · Apr 14, 2016 at 01:25 PM

Move the line 4 animator.SetBool("Punching", false); somewhere else inside a function (Start?) or delete it completely and set the parameter "Punching" to false in the editor.

Also, Line 23 accesses a variable "anim". Maybe you meant "animator"?

Edit: Finally, Line 22 uses the syntax for C# yields. ("yield return new WaitForSeconds"). The syntax for UnityScript is "yield return WaitForSecond...". (No need to use the new operator in UnityScript).

Edit Edit: Aaand spotted another error: Look where your Update function starts and where it ends. Your function "StopAnimation" is inside the Update function. That is not legal in neither UnityScript nor C#. You have to close Update() first and then start the StopAnimation function.

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 DogPoo74 · Apr 15, 2016 at 08:24 AM 0
Share

thanks for your answer but that doesn't work, i still have this message (22,13): UCE0001: ';' expected. Insert a semicolon at the end.

avatar image Immanuel-Scholz DogPoo74 · Apr 15, 2016 at 08:46 AM 0
Share

Added comment about yield statement. In JavaScript, you don't write the new. See also link text

avatar image DogPoo74 · Apr 15, 2016 at 11:44 AM 0
Share

sorry that doesn't work either, always this error (23,9) UCE0001: ';' expected. Insert a semicolon at the end.

avatar image DogPoo74 · Apr 15, 2016 at 01:30 PM 0
Share

ok like this ?

 #pragma strict
     
     var animator : Animator;
     animator.SetBool("Punching", false);
     
     
     function Start () 
        {
        animator = this.GetComponent(Animator);
        }
     
     function Update () 
        {
     
        if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.G)) 
           {
            animator.SetBool("Punching", true);
            StartCoroutine("StopAnimation");
           }
        }
     
        IEnumerator StopAnimation()
           {
            yield return WaitForSeconds(0.5);
            anim.SetBool("Punching", false);
           }

it still saying it's missing a semicolon

avatar image meat5000 ♦ DogPoo74 · Apr 15, 2016 at 02:09 PM 0
Share

You didnt follow the advice. Delete line 4. You moved it but didnt delete the original. You cant make statements like that outside of functions.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why is my cube not following the other the way i want ? 1 Answer

How to Undo a lot of created objects at once? [Solved] 1 Answer

How to make hundrenths of seconds in C#? 1 Answer

Sprite renderers not rendering on Instatiated objects 2d 0 Answers

Moving object alone y-axis 1 Answer


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