Direction Of Bullets(Help)

Ok, I am trying to make a gun shooting and working so it’s working but the bullets fly only in one direction.

Which is driving me insane.

This is the Script that I stick on to the player but the problem I would assume is in the bullet script or bullet spawn so I provided both. Thank you.

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

public class Shooting : MonoBehaviour
{
    public GameObject bullet;
    public GameObject bulletSpawn;
    public float fireRate;


    private Transform _bullet;
    // Start is called before the first frame update
    void Start()
    {
      
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
            Fire();
    }

    public void Fire()
    {
       _bullet = Instantiate(bullet.transform, bulletSpawn.transform.position, Quaternion.identity);
    }
}

And this code goes on to the bullet

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

public class Bullet : MonoBehaviour
{
    public float aliveTime;
    public float damage;
    public float movSpeed;

    public GameObject bulletSpawn;
    // Start is called before the first frame update
    void Start()
    {
        bulletSpawn = GameObject.Find("Bullet Spawn");
        this.transform.rotation = bulletSpawn.transform.rotation;
    }

    // Update is called once per frame
    void Update()
    {
        aliveTime -= 1 * Time.deltaTime;

        if (aliveTime <= 0)
            Destroy(this.gameObject);

        this.transform.Translate(Vector3.forward * Time.deltaTime * movSpeed);
    }
}

Hello, if you instantiate a GameObject and use Quaternion.identity as rotation and when it’s not parented to an other GameObject, which means it’s in the highest level in your scene, then translate Forward will always move the objects in the same direction. You have to set the rotation of your projectile on instantiation to the forward world rotation of your gun (if the forward rotation of your gun is the rotation you want the projectile to fly), then tranform forward will move it in the forward direction the gun had.
Greetings.

Vector3.forward is basically the global North.

You want transform.forward which is the forward of “this” object.

Or use bulletSpawn.transform.forward.

If using physics on the bullet, add force in the direction the gun is pointing despite rotation of bullet. The gun barrels transform forward. Or whichever direction it may end up being.