Trying to shoot projectile at the angle of camera

I’ve been able to figure out how to shoot it forward, but I can’t rotate it so that for example, if I were to shoot an arrow, the tip won’t point away from the character. I basically just want the projectile to point where it is travelling.

My current code:

clone = Instantiate(projectile, cam.transform.position, projectile.transform.rotation);

        Vector3 camDir = transform.forward;

        clone.GetComponent<Rigidbody>().AddRelativeForce(camDir * projectileSpeed);

Projectile is the prefab I’m instantiating, cam is the main fps camera and projectileSpeed is the speed the bullet travels at. Everything else should be pretty self explanatory.

If there is any better, easier or more efficient way to do what I’ve done above, please don’t hesitate to tell me. Any help is appreciated!

Shouldn’t your Instantiate match the camera rotation as well as position?

clone =Instantiate(projectile, cam.transform.position, cam.transform.rotation);

I tried that, but the projectile gets shot in a different direction than what I’m facing and the projectile still isn’t facing away from the player. I think that if the camera is rotated 30 degrees, the the projectile gets shot in 30 degrees relative to the camera, but I’m not sure.