How to shoot in any direction?

Hi, I am a new.

I have a question that I could not solve, as the title says I want to make a shot to any direction in 2D. One way I’m trying is for the bullet to move by force…

A code

private void Disparar()
    {
        Vector2 direccion = (mira.position - bocaArma.position).normalized;
        GameObject bala;
        bala = Instantiate(municion, bocaArma.position, bocaArma.rotation);
        rbMunicion.AddForce(fuerzaInicial * direccion, ForceMode2D.Impulse);
        cantidadBalas--;
    }

But what happens is that the bullet remains static and does not go to any direction, the bullet has a dynamic rigidbody. There is also the creation of a ray but this time I wish there was an object.

because you didnt reference the bullet
I thing you just addforce to a player or gun or something

anyway to fix this, try making script for bullet, and everytime it enabled try addforcing to right

Now the bullet goes in one direction no matter what it does. What I did was change the bullet script to add direction and strength, as seen in the script; One problem I have is that the bullet is a prefab and I had to prefab the sight and muzzle of the weapon.

public class Bala : MonoBehaviour
{
    public Rigidbody2D rb;
    public Transform mira;
    public Transform bocaArma;
    public float fuerzaInicial;
    public float tiempo;
    private float t;

    void Start()
    {
        t = tiempo;
    }

    void Update()
    {
        Vector2 direccion = (mira.position - bocaArma.position).normalized;
        rb.AddForce(fuerzaInicial * direccion, ForceMode2D.Impulse);

        if(t <= 0)
        {
            Destroy(gameObject);
        }
        else
        {
            t -= Time.deltaTime;
        }
      
    }
}

Another little thing, I do so that the bullet when colliding with the player or an enemy does not push him or transfer the force to him.

bullet always goes one direction, because that’s what the normal bullet does.

you have to make Instantiated bullet follow the rotation of Gun’s barrel position

and to interact any object. you have to add Collider in objects

But that would give problems since it would not cover the entire “firing zone”? it would be better to add a force to it but my script must have some problem since it does not run as I wish?

Any other opinions?