2D Bullet not moving forward and creating multiple shots.

I’m working on a 2d Sidescroller and running into an issue with the bullet movement. The instantiate works fine at creating the projectile on input, but will spam creation of the projectile for the duration of the Mouse0 press (not once per instance). Likewise, the bullet itself will not move forward, even with the speed set at hugely high levels.

Here’s the governing snippet and variables.

private Rigidbody2D ammoUsed;

private Transform gunBarrel;

private int shotSpeed;

void StateShoot() {
    Rigidbody2D bullet;
    bullet = Instantiate(ammoUsed, gunBarrel.position, gunBarrel.rotation) as Rigidbody2D;
    bullet.rigidbody2D.AddForce(bullet.transform.forward * shotSpeed);
    Debug.Log("You shoot something!");
    if (Input.GetKeyUp(KeyCode.Mouse0)) {
        if (onGround == false) {

Thanks in advance for any assistance.

Maybe you have “Kinematic” set to true?

The spawning of multiple bullets at once may be due to the condition you’re checking in your update loop. Are you using “Input.GetKey(KeyCode.Mouse0)” or “Input.GetKeyDown(KeyCode.Mouse0)”? The former will fire as long as the mouse button is held, whereas the latter will fire once per click.