aiming at center of screen

i am making a fps and i want to know how i would make it so my gun was always facing the center of the screen. i already have a crosshair at the center and i know my bullets are not hitting there. the bullet has no gravity so it just goes straight. i want to make the bullet hit exactly where i am aiming in the middle of the screen. i hope you understand.

I am not sure on your issues but let me offer you some history of what I did in my shooter...

There are design implications to bullet architecture that comes with their own choices... Normally you do one of the following:

  1. If you simulate a bullet moving through the world, as in you instantiate a bullet and give it velocity and physics, I recommend doing a ray cast of old -> new position each Update handling the collision info if it comes and giving the bullet a short lifespan (2 seconds?).

  2. If you want to immediately know at the time of firing a bullet whether you hit the target, then do a ray cast off your camera's foward vector in world space yet still tell the bullet to travel for visual only. I recommend setting an end destination point from the collision info and lerping from your instantiation point -> end point.

If you are referring to the visual of your gun, I would child the gun to your camera so when your camera is transformed, the gun is transformed with it