Help with a simple shooter

Hello Guys,

Apologies if this appears to be a repeated question, but I am using this code and I cannot get the addforce to work on the bullets. Im 100% sure they have a rigid body and I’ve toggled ‘Is Kinematic’ on and off to no avail.

Here is the code.

var Bullet : Transform;
var bulletSpeed = 500;

function Update ()
{
	if(Input.GetButtonDown("Fire1"))
    {
    Instantiate(Bullet,transform.position + (transform.forward * 2),transform.rotation);
    Bullet.rigidbody.AddForce(transform.forward * bulletSpeed,ForceMode.Impulse);
    }
}

edit: the issue is that the bullets are stacking and not moving.

Your main problem is that you are trying to AddForce() to the prefab used to instantiate the bullet not to the bullet created. Try it this way. Note I changed your bullet to a GameObject (not strictly necessary).

var Bullet : GameObject;
var bulletSpeed = 500;

function Update ()
{
    if(Input.GetButtonDown("Fire1"))
    {
    var go = Instantiate(Bullet,transform.position + (transform.forward * 2),transform.rotation);
    go.rigidbody.AddForce(transform.forward * bulletSpeed,ForceMode.Impulse);
    }
}

Why not just set the velocity directly?

var go = Instantiate(Bullet,transform.position + (transform.forward * 2),transform.rotation);
go.rigidBody.velocity = transform.forward * bulletSpeed;