- Home /
3 java errors on a basic shooting script?
I'll start off by saying this: I KNOW NO JAVA SCRIPT. I'm working from this tutorial: http://www.youtube.com/watch?annotation_id=annotation_934937&v=wfpZ7_aFoko&feature=iv[Linky][1] and it calls for a basic script. but as the tittle say, i get three errors on said script. Here's the script:
var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab: Transform;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
if (Input. GetButtonDown("Jump"));
{
var bullit = Instantiate(bullitPrefab,
GameObject.Find("Fire Spawn").transform.position, Quaternion.identity);
}
}
@script RequireComponent(CharacterController);
Here are the errors:
Assets/Move Around.js(16,33): BCE0043: Unexpected token: var.
Assets/Move Around.js(16,36): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Move Around.js(21,9): BCE0044: expecting EOF, found '}'.
the first two seemed strait forward enough, but i tried the obviouse and it didn't seem to work (but again, i don't know java).
Thanks!
It's much easier to read formatted code, even if it means we need to count to the line ourselves. $$anonymous$$y answer should fix the errors for you.
Thank you so much $$anonymous$$arowi! That made everything work. and thanks for the tip on the code formatting. i didn't know we could do that!
No worries, you just highlight the section you want formatted and press the little button with 0s and 1s. Good luck!
Answer by · Feb 01, 2011 at 02:02 AM
Remove the semi-colon after both:
if (Input. GetButtonDown("Jump"));
and
@script RequireComponent(CharacterController);
Answer by tertle · Feb 01, 2011 at 01:21 AM
14 if (Input. GetButtonDown("Jump"));
shouldn't have a semicolon after that. what it should look like
if (Input. GetButtonDown("Jump"))
{
//blahblah
}
thx! that seemed to solve all of them except the EOF error.