Insurgency Sandstorm style reflex sight

I’m working on a shooter, and everything is working mostly fine, however I’m thinking of adding attachment to weapons, but because of how the game works I want to make sure that the reflex sight always stay centered to the center of the screen, similar to Insurgency Sandstorm.

Here you can see that no matter how fast the player shake their screen the red dot stay centered despite the weapon moving (which isn’t how actual reflex sight would work, but its fun and responsive, and that’s what matter)

I’ve been trying to think of how this could be achieved, I thought of maybe using surface gui on the sight, but I have no idea how I would calculate the dot to stay centered to the screen.
I can also use actual reflex sight, but since the gun always shoot to the center of the screen, an off-centered sight would be frustrating to play with.

Extra note: I would also want to learn how to hide the gun when the player use a zoom optic without using picture-in-picture like this part

(See how the gun isn’t visible in the sight despite not using picture-in-picture)

3 Likes

Just enable a dot on the screen when you aim in using a boolean and some timing. Its not really worth doing a bunch of random math for something so simple.

You can also check the magnitude of the aim part from the center of the screen. Using this magnitude we just check if it’s below a value, then enabling the red dot on the screen. Since our magnitude counts as a radius, it classifys as a circle. So imagine a circle in the center of your screen and when the weapon aim part goes within the radius of the circle, we switch the red dot on.

Simple yet effective and doesn’t require a math intensive solution.

1 Like

The first solution seems like a very hacky way to do it.
Yes its simple but this is going to be a problem when you have multiple guns and multiple reflex sight, as you would have to manually change the timing of every attachment/gun

The second solution is definitely worth trying, however not all sight is a circle
image

image

It would work on non-circular sight yes, it would just look weird enough to be noticable.
Here’s a little animation I made on what simply enabling and disabling the crosshair would look like

Also when reloading, the gun tends to move around a lot, this could lead to accidental activation of the crosshair that would be in the wrong place.
(Like the gun aiming upward so the crosshair appears on top of the sight)

The more complex solution requries understanding parralax free reflexs. A similar turorial was made and you can find it here → Implementation of optical scope shadow, effect of scope parallax adjustment, and parallax-free reflex sight

A lot of these things can be replicated pretty easily using some simple algebra which you can consider the “hacky” way. Like creating a virtual box and detecting if your within it(as I mentioned before but with a circle)

To make a box, literally take 2 points and check if your point is in it. Super simple :ok_hand:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.