Rotate bullet in direction

Hi,
I am currently trying to make a physically accurate firearm system. The only problem is that I cannot get my bullet facing the direction it is currently going.

Ray ray = new Ray();
        ray.origin = playerCamera.transform.position;
        ray.direction = playerCamera.transform.forward;
     
        direction = (ray.GetPoint(69) - firePoint.position).normalized;
       
        GameObject bulletInstance = Instantiate(bullet, firePoint.position, Quaternion.identity);

        bulletInstance.transform.forward = direction;

        Vector3 bulletForce = direction * bulletVelocity;

        bulletInstance.GetComponent<Rigidbody>().AddForce(bulletForce, ForceMode.Impulse);

Whatever I try to do, I cannot get the bullets to face in the direction they are going, they always point up.

GameObject bulletInstance = Instantiate(bullet, firePoint.position, playerCamera.transform.rotation);
bulletInstance.GetComponent<Rigidbody>().velocity=playerCamera.transform.forward*20f;

The bullets still just face upwards relative to the camera

You can either use your modeling program to orientate the bullet so that its tip points along the z axis. Or do this:

GameObject bulletInstance = Instantiate(bullet, firePoint.position, playerCamera.transform.rotation);
bulletInstance.transform.up=playerCamera.transform.forward;
bulletInstance.GetComponent<Rigidbody>().velocity=Camera.transform.forward*20f;

Hi,

What you could do is add a script to your bullet GameObject, so that you’re rotating the bullet to be looking at the same direction of the velocity vector. Using something like :
Quaternion.LookRotation(rigidbody.velocity);
Should get you the correct rotation. Set the rotation of the rigidbody to change the bullet rotation using the physics engine.

Thanks, guys!

Now go shoot something…