Expecting :, Found bulletPrefab, Help once more!

"expecting :, found 'prefabBullet'.

i can’t see why it’s expecting :, Anyone?

 var target : Transform;
var prefabBullet : Rigidbody;
var shootForce;
var range = 10;
var LastFired = 0.0;

function Update () {

//Check if the player is in range
if(Vector3.Distance(transform.position, target.position) < range)
	/*{ // If the player is in range, Start shooting
		Instantiate(prefabBullet, transform.position, Quaternion.identity);
		prefabBullet.rigidbody.AddForce(transform.forward * shootForce);
	}*/
	
if((Time.time > LastFired +1.0)  (Vector3.Distance(transform.position, target.position) < range));
	{
		Instantiate(prefabBullet, transform.position, Quaternion.identity)
		prefabBullet.rigidbody.AddForce(transform.forward * shootForce);
	}
}
Instantiate(prefabBullet, transform.position, Quaternion.identity)

is missing a ; at the end :slight_smile:

i’m a idiot!, Thanks, though the error said “:, not ;” :smile:

EDIT Now it’s saying expecting :, found ';'. :frowning:

You also have a ; at the end of the 2nd if statement. Remove that and it should be fine :slight_smile:

Ahh didn’t see that :P, Now i have a new problem

 No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(UnityEngine.Rigidbody, System.Type, UnityEngine.Vector3, UnityEngine.Quaternion)' was found.

I give up

Fixed, but it’s not shooting

 var target : Transform;
var prefabBullet : Rigidbody;
var shootForce;
var range = 10;
var LastFired = 0.0;

function Update () {

//Check if the player is in range

	/*{ // If the player is in range, Start shooting
		Instantiate(prefabBullet, transform.position, Quaternion.identity);
		prefabBullet.rigidbody.AddForce(transform.forward * shootForce);
	}*/
	
if((Time.time > LastFired +1.0)  (Vector3.Distance(transform.position, target.position) < range))
	{
		Object.Instantiate(prefabBullet, Rigidbody, transform.position, Quaternion.identity);
		prefabBullet.rigidbody.AddForce(transform.forward * shootForce);
	}
}

There is no version of Instantiate that takes 4 parameters.

Object.Instantiate(prefabBullet, Rigidbody, transform.position, Quaternion.identity);

should probably be:

Object.Instantiate(prefabBullet, transform.position, Quaternion.identity);

Oh, thanks…

New code, new problem

 var bulletPrefab : GameObject;
var power  = 5000;
var LastFired  = 0;
var target;
var range = 15;
function Update () 
{

	if((Time.time > LastFired +1)  (Vector3.Distance(transform.position, target.position) < range))
	{
		Object.Instantiate (GameObject, transform.position, Quaternion.identity);
	}

		rigidbody.AddForce(Vector3(0,0,power));
}

Fixed it :smile:

EDIT Ok, seems liek the whole thing has stopped working, the turret wont even look at me any more