Trouble Instantiating Projectiles

Attempting to create a top down shooter where the player can shoot zombies that spawn. I’m having trouble getting the projectiles to work, however. I’m new to unity so bear with me.

public Rigidbody projectile;

if (Input.GetMouseButtonDown(0))
if (bulletCount > 0) {
anim.Play (“Strike”);

			ammo -= 1;
			Rigidbody bullet = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
			Physics.IgnoreCollision(bullet.collider, collider);
			bullet.velocity = transform.TransformDirection(new Vector3(0, 0, bulletSpeed));


This is the player’s function that creates the bullet.

public class bullet : MonoBehaviour {

public void OnTriggerEnter(Collider c) {
	Debug.Log("zombie died");



This is the bullet’s function. Whenever I click in game, it tells me there is a nullreference exception, object reference not set to an instance of an object. I don’t understand the issue here.

Shouldn’t you spawn a gameobject that has a rigidbody attached, and then apply the physics to that rigidbody?
You are spawning a rigidbody directly i think. (Not familiar with C# yet.)