velocity of bullet in rifile rotation

Hi all,

I am beginner to unity 2d,I am trying to rotate a gun and shoot bullets in the gun direction in unity 2d.
! have two scripts:
below one is for barrel point.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class BarrelScript : MonoBehaviour {
	public Transform barrel;
	public Rigidbody2D bullet;
	public float fireSpeed = 500f;
	// Use this for initialization

	
	// Update is called once per frame
	void Update () {
		Fire ();
	}
	void Fire ()
	{
		if (Input.GetButtonDown("Fire1")) {
			Rigidbody2D firedBullet = Instantiate (bullet, barrel.position, barrel.rotation) as Rigidbody2D;
			firedBullet.AddForce (barrel.up * fireSpeed);
			
	}
}

}

another script for rotating gun I am able to rotate the gun but my problem is I am not able to shoot the bullet in barel position.

please help me out.
Thank you.

Are your bullets flying up instead of forwards? You’re adding force in the up direction of the barrel, which would normally be vertical. You probably want the forward direction, which should be down the Z axis of your barrel.

firedBullet.AddForce (barrel.forward * fireSpeed);