Hello,
I am working on a top down shooter for practice project. The project has one scene, “Testy” that has a plane named “Floor”; a cube named “Ship”; a small cube named “Bullet”; Lights and a camera. Bullet has a rigidbody. Ship has a rigidbody, a movement and shoot script and a camera child. I am having trouble with the shoot script.
#pragma strict
//A java script to shoot a bullet from the ship
function Start () {
}
//Here Unity says the Bullet variable is undefined
var Bullet : Transform;
function Update ()
//This should generate a bullet at the middle of the ship object
{
if(Input.GetKeyDown(KeyCode.Mouse0))
{
Instantiate(Bullet,transform.position,Quaternion.identity);
Bullet.rigidbody.AddForce(transform.forward * 1000);
}
}
With a search of google and youtube I can’t seem to find a way to fix this.