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!
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.
thanks for your answer but that doesn't work, i still have this message (22,13): UCE0001: ';' expected. Insert a semicolon at the end.
Added comment about yield statement. In JavaScript, you don't write the new. See also link text
sorry that doesn't work either, always this error (23,9) UCE0001: ';' expected. Insert a semicolon at the end.
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
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.