Firing toward center of screen in 3D first person shooter?

I am trying to set up a shooting mechanic for a first person shooter in which the projectile will always fire to a crosshair at the center of the screen. I’ve googled how to do this, copied the logic verbatim but it would appear that the info is out dated. I know I’ve got to use ScreentoWorldPoint in some way but cannot figure out the correct way to use it. Please help.

In case you’re using raycasts to do that, you can use this code:

public Transform CameraTransform;

public void Shoot(){

     RayCastHit hitPoint;
     Physics.Raycast (CameraTransform.position, CameraTransform.forward, out hitpoint)
}

You should check this youtube tutorial form Brackeys:

I hope this helps you :slight_smile: