Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Sensitivity and Mouse Polling

ecx86 edited this page Mar 20, 2016 · 2 revisions

Sensitivity

The Minecraft client polls the mouse and adjusts the player's view angles in a very peculiar way.

This assumes smooth aim is off.

On Frame

  1. Poll the mouse to see how many pixels it has moved on the x (horizontal) and y (vertical) axes.
  2. I will refer to the pixel movement on x and y as dx and dy respectively.
  3. The player's sensitivity ranges from 0.0 (yawn) to 1.0 (hyperspeed). 0.5 is the default sensitivity (100%). I will refer to this as s.
  4. The procedure to update the player's angles is as follows:
s = 0.6s + 0.2
s = s^3 * 8.0
dx *= s
dy *= s
if (invert mouse is enabled)
    dy *= -1
player.yaw += dx * 0.15
player.pitch -= dy * 0.15
if player.pitch > 90
    player.pitch = 90
if player.pitch < -90
    player.pitch = -90
Clone this wiki locally