- Home /
Var Error Help
I have a problem, it gives me the Unexpected Token: Var error. I am trying to make a rocket launcher and here is my code. Tell me if you can improvement.
#pragma strict
function Start ()
var projectile : Rigidbody;
var speed = 20;
function Update()
{
if( Input.GetButtonDown( "Fire1" ) )
{
var instantiatedProjectile : Rigidbody = Instantiate(
projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider,
transform.root.collider );
}
}
This is it
Comment
Answer by syclamoth · Apr 03, 2012 at 11:17 PM
See at the start, you have this line?
function Start ()
This is invalid syntax. You need to either add a {} to the end of that (since the function requires a body), or delete it entirely until you have something you want to put into the Start function.
Your answer
Follow this Question
Related Questions
Help me with this Unexpected token error 1 Answer
Unexpected Token 3 Answers
Unexpected token: targetPos 1 Answer
simple coding problem 1 Answer