3rd person camera pointing system

Hello everyone.

I’ve figured out how to make a working “aiming” system for my 3rd person shooter controller. I’ve got a raycast from the camera, and the bullets go from the player to where the raycast (where the camera is looking, the center of the screen) has collided, so the bullets always go to where the center of the screen is, like on most other third person shooter games (if not all of them).

The problem is when the raycast doesn’t collide, like when i’m pointing to the sky. Where should the character’s gun point in that case?

Thank you very much

I would create an invisible boundary that encompasses your whole scene. When you ray doesn’t hit anything in the scene, it hits the boundary.

You can constrain the max distance of your Raycast with the “distance” parameter (for example, use a value around the farClip value of your camera as distance). Then if there is no hit, origin+distance*direction marks the endpoint of your ray.


just put a cube game object aligned with the camera really far maybe something like 1000 units and remove the renderer so the raycast is always going to be hitting something.