Im having trouble with my turrets AI script in javascript. When I try to play the game it comes up with variouse errors which are in the link below, one of the main errors is an “unexpected token”…please help.
You shouldnt have a semicolon after Shoot(seconds) and after (seconds!=savedTime)
The last two should fix after you remove the semicolons.
I’m not sure if it is only C# but you should have a cast on your instantiate
var bullet = Instantiate(bulletPrefab ,transform.Find(“Sphere”).transform.position ,Quaternion.identity) as GameObject;
Your new Shoot function
function Shoot(seconds)
{
if(seconds!=savedTime)
{
var bullet = Instantiate(bulletPrefab ,transform.Find("Sphere").transform.position ,Quaternion.identity) as GameObject;
bullet.rigidbody.AddForce(transform.forward * 1500);
savedTime=seconds;
}
}