BCE0043 unexpected token: ")"?
Im new to coding, and I got error Assets/Scripts/cannon shoot.js(10,64): BCE0043: Unexpected token: )., I know that means im not using ")" right, but I can't figure out whats wrong with my code. I checked to make sure each "(" had a corresponding ")", so whats wrong with my code? just so you know, the code is in Javascript, my game is 2D, and im using it to make a bubble fly up when i click.
Heres my code: #pragma strict
function Start () {
}
function Update () {
if (Input.GetMouseButtonDown) transform.Translate (Vector2(0,1,));
}
Answer by rslnautic · Apr 17, 2016 at 06:29 PM
Vector2 (x,y): Vector2(0,1) not Vector2(0,1,)
Vector3(x,y,z): Vector3(0,1,0)
#pragma strict
function Start () {
}
function Update () {
if (Input.GetMouseButtonDown) transform.Translate (Vector2(0,1));
}
Tip: Use Vector2.up instead Vector2(0,1), it's an static var of struct Vector2 to shorthand for writing Vector2(0, 1). it's better. Link: http://docs.unity3d.com/ScriptReference/Vector2-up.html
You are welcome! :) mark the answer as best answer to complete this question. Thank you!