1
\$\begingroup\$

I am creating a FPS game online. I want the user to be able to use a sensitivity they are familiar with from games they've played. In this case, I want them to use their Fortnite sensitivity.

I am trying to figure out the Math behind it all.

I have figured out how to change the sensitivity in the PointerLockerControls.js file and can edit it from my main js file.

function onMouseMove( event ) {

    if ( scope.isLocked === false ) return;

    var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
    var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;

    euler.setFromQuaternion( camera.quaternion );

    this.speedFactorX = 0.002;
    this.speedFactorY = 0.002;

    euler.y -= movementX * scope.speedFactorX;
    euler.x -= movementY * scope.speedFactorY;

    euler.x = Math.max( - PI_2, Math.min( PI_2, euler.x ) );

    camera.quaternion.setFromEuler( euler );

}

I want to know what type of unit the '0.002' is.

In fortnite, I have my sensitivity at '0.08'. Obviously, this is way too fast to replace the speed factor values.

What kind of math do I need to match the users sensitivity in fortnite, to the speed factor values?

Hope someone can understand what I mean. Thanks!

This may help with the fortnite values - https://jscalc.io/calc/RTCJTLMts42GYfWf

I will be using the fortnite slider.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

The type of unit for 0.002, as the name suggests, is a factor. An arbitrary number chosen to lower the rate of turning so that tiny mouse movements don't spin the camera 100 times.

To get fortnite-like aim, you need to disable mouse acceleration(enabled by default in windows) and measure the distance your mouse travels for a complete rotation in fortnite. Then, you need to match this distance in your engine. If your mouse moves 5'' in fortnite for a complete rotation, and in your engine it does 1.5 rotations for 5'', you need to divide your factor by 1.5. If your engine does 0.1 rotations in 5'', divide by 0.1.

For vertical sensitivity, use aiming upward to downward instead of rotations.

There's the possibility that fortnite uses a non-linear function for its sensitivity value, so that 0.09 may be double or triple what 0.08 was. This seems unlikely though, you shouldn't need to worry about it.

Some games(not fortnite) also smooth the camera. You can do this by keeping your existing camera code, but adding a new camera whose position is updated every frame:

smoothCamera.quaternion.slerp(camera.quaternion, Math.min(1, clock.getDelta()*50));
\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .