Free aim/deadzone for fps camera

duncanbellsa

New member
Hi everyone,

I'm a novice programmer looking to make an FPS with a Red Orchestra/Insurgency style aiming system, where there is a "dead zone" that the aiming takes place in. Essentially, aiming point of the gun moves around on the screen, and is not locked to the middle.

I've played around with the first person controller, and I can get the bullet to fire from the gun instead of the camera, but I am battling to figure out how to create a deadzone. There only seems to be settings to tweak the sway and bobbing, but no indication of a deadzone.

Any suggestions?

The below video shows an example of what I am looking to achieve:

Thanks in advance!
 
The weapon will aim towards the CrosshairsMonitor (whether or not a the Crosshairs sprite exists). In this situation you could create a script which moves the transform of the CrosshairsMonitor and the weapon will also move in that direction.
 
Ah I see - when I set up my first weapon for some reason it was not matching the crosshair, but I copied and pasted from the demo scene and I see it matches the crosshair correctly. Thanks!
 
So I managed to get it working properly, I ran into an issue which took me a while to solve:

Zooming/FOV
Since I was moving the crosshair around, if I zoomed in the gun would jump,since the cursor location has actually moved inwards due to the zoom/fov change. The solution here was to match the overlay camera FOV with the normal view FOV, and remove the zoom.

But other than that, it looks great and I'm super happy (please ignore ugly map and horrible AI):


I've also attached the script if anyone wants it:

Instructions on how to use:
-Attach the script to the "Crosshairs" gameobject.
-In the "MyCanvas" parameter, drag in the parent canvas object of the crosshair.
-Deadzone values can be tweaked if need be
-Ensure that your fps and overlay camera fov's are the same, and zoom functionality is disabled
 

Attachments

  • crosshair_mover.cs
    1.6 KB · Views: 13
Nevermind, I just had to dial it up to see t he effect, my bad. Thank you so much for this sweet script!


Instructions on how to use:
-Attach the script to the "Crosshairs" gameobject.
-In the "MyCanvas" parameter, drag in the parent canvas object of the crosshair.
-Deadzone values can be tweaked if need be
-Ensure that your fps and overlay camera fov's are the same, and zoom functionality is disabled


Do you mean the "crosshairs" game object on the UI canvas? Or like the physical crosshairs game object? I don't notice any difference with it attached to the UI crosshairs object.
 
Last edited:
Top