- Home /
Question by
AndroidWG · Aug 04, 2015 at 01:17 AM ·
javascripterror
"';' expected. Insert a semicolon in the end" error
I'm a noob in scripts, and I'm getting this error on this script:
function Update () {
if(Input.GetMouseButtonDown(0))
{
bDragging = true;
oldPos = transform.position;
panOrigin = Camera.main.ScreenToViewportPoint(Input.mousePosition);
}
if(Input.GetMouseButton(0))
{
Vector3 //Unity says there should be an semicolon right here// pos = Camera.main.ScreenToViewportPoint(Input.mousePosition) - panOrigin;
transform.position = oldPos + -pos * panSpeed;
}
if(Input.GetMouseButtonUp(0))
{
bDragging = false;
}
}
Unity is giving me this error, and as far as I know, that error shouldn't happen. Can someone help me?
Comment
Best Answer
Answer by tanoshimi · Aug 04, 2015 at 06:03 AM
If you're gonna use UnityScript, you need to learn the right syntax...
var pos : Vector3 = Camera.main.ScreenToViewportPoint(Input.mousePosition) - panOrigin;
Answer by Dave-Carlile · Aug 04, 2015 at 01:18 AM
Are you coding in C# or UnityScript? Your function is declared using UnityScript syntax, but you're declaring the Vector3 using C# syntax.
Your answer