- Home /
shoot script is not working
this is probably a stupid question but i cannot get my shoot script to work. i am a noob to scripting and this is the first script that i have worked on. it is supposed to spawn a rigidbody game object with force in a direction from a empty object when i left click.
here is the script
var bullet : Transform;
function update () { if(input.GetMouseButtonDown(2)
Instantiate(Bullet,transform.position, Quaternion.identity);
Bullet.rigidbody.AddRelativeForce(transform.forward * 15); }
and it is giving me this error. BCE0044: expecting ), found 'Instantiate'
Answer by applejuices · Dec 09, 2013 at 03:44 AM
var bullet : Transform;
function update () { if(input.GetMouseButtonDown(2)){
Instantiate(Bullet,transform.position, Quaternion.identity);
Bullet.rigidbody.AddRelativeForce(transform.forward * 15); }
This should fix it. atleast the error you have. also I suggest putting a game empty and then tell it to shoot out of the forward of there, its easier and less glitchy.
function update () {
if(input.Get$$anonymous$$ouseButtonDown(2)){
Instantiate(Bullet,transform.position, Quaternion.identity);
Bullet.rigidbody.AddRelativeForce(transform.forward * 15);
}
}
I suggest you never combime more than one thing in one line.