i keep getting this error "Assets/scripts/shootsemiauto.js(7,121): BCE0043: Unexpected token: )."
`var bulletPrefab : Transform;
function Update () {
if(Input.GetButtonDown(LeftMouseButton))
{
var bullet = Instantiate (bulletPrefab, GameObject.Find ("spawnPoint").Transform.position , Quaternion.identity,);
bullet.rigidbody.AddForce(transform.forward * 200)
}
}`
There's a "," behind Quaterion.identity
Hi,
You had numerous errors actually.
Here is the code fixed:
var bulletPrefab : Transform;
var spawnReference : Transform ;
function Update () {
if ( Input.GetMouseButtonDown(0) ){
if (spawnReference!=null){
spawnPoint = spawnReference.position;
}else{
Debug.LogError("WArning: no spawnReference declared");
return;
}
var bullet = Instantiate (bulletPrefab,spawnPoint, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * 200);
}
}