- Home /
Question by
seanybaby2 · Apr 28, 2013 at 12:01 AM ·
javascriptunexpected token
unexpected token: savedTime
I keep getting this unexpected token:savedTime error and I have no idea why. Your help is much appreciated. Thanks.
var LookAtTarget:Transform;
var damp = 6.0;
var bullitPrefab:Transform;
var bps=1.00;
private var savedTime;
function Update()
{
if(LookAtTarget)
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);
if(Time.time > bps+savedtime)
{
savedtime=Time.time;
Shoot();
}
}
}
function Shoot()
{
if(seconds!=savedTime)
{
var bullit = Instantiate(bullitPrefab,transform.Find("shoot_turret").transform.position, Quaternion.identity);
bullit.rigidboy.AddForce(transform.forward * 1000);
savedTime : float = 0;
}
}
Comment
Best Answer
Answer by Eric5h5 · Apr 28, 2013 at 12:06 AM
You can't define the type of a variable when you're just using it. You should, however, define the type when you declare it (which currently you don't), either explicitly, or implicitly by supplying a value.