Force Not Being Added in Correct Direction

I have a projectile, which is supposed to be firing in the direction of the camera. I’ve been trying for hours now but I still haven’t figured it out. I am very new to Unity and some help would be much appreciated.

Bullet.GetComponent ().AddForce (Camera.main.transform.forward);

The code above is what I’m using to Add Force in the direction of the camera. It adds the force perfectly fine, but not in the right direction. The force is being added directly upwards instead of towards where the camera is pointing. Could someone possibly tell me why this might be happening?

Double-check where your bullet is instantiated. Is it bullet being spawned within the collider of the gun it’s fired from (or any other already-existing collider)? Are collisions not disabled between the bullet and gun?

If that is the problem, then there’s the possibility that you’re instantiating the bullet, adding a force to start it moving, then it’s realizing it’s colliding with the gun and the force is being redirected to propel the bullet in the wrong direction.