Mouse polling rate too low. How to fix?

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
3D Car Pack 1
$2.99 USD
3D models + Rendered Low-Poly Cars in isometric, top-down, and side angles.
  • Hi. I'm trying to create a platformer game prototype with mouse functionality.

    I have a character that uses the Platform and ScrollTo behaviors, and a sprite that follows the Mouse X and Y.

    When the character moves, the sprite starts to lag behind a bit, as if the polling rate is too low. This gets worse when using a fixed framerate mode with low framerates, and better (though obviously unmaintainable) when using uncapped framerate modes.

    Is there any way I can solve this in a way that doesn't involve uncapping the framerate?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Are you sure it's the mouse polling rate and not just frame latency, which would add the kind of delay you describe? The lower the framerate the higher the latency from input to rendering, and the higher the framerate the lower the latency. Construct uses high-frequency polling specifically to reduce the input latency (via pointerrawupdate) and I just checked that on my system, even though the display is refreshing at 60 Hz, mouse input is being received at ~125 Hz.

  • Are you sure it's the mouse polling rate and not just frame latency, which would add the kind of delay you describe? The lower the framerate the higher the latency from input to rendering, and the higher the framerate the lower the latency. Construct uses high-frequency polling specifically to reduce the input latency (via pointerrawupdate) and I just checked that on my system, even though the display is refreshing at 60 Hz, mouse input is being received at ~125 Hz.

    It could be frame latency, then? But I should not be seeing the kind of delay that I'm seeing at a solid 60 FPS. The ideal outcome is that my mouse pointer sprite is positioned exactly where the cursor physically is, even after calculating anything like platform movement.

  • With the mouse object you can set the cursor image from a sprite. That won’t be a frame behind.

  • The ideal outcome is that my mouse pointer sprite is positioned exactly where the cursor physically is

    I don't believe this is actually possible with any technology. IIRC, the system mouse cursor is rendered with a special low-latency hardware overlay that bypasses much of the existing rendering system to allow things like continuing to respond when the app/system is busy/hung. On the other hand any app on the system itself will go through the usual GPU rendering pipeline, which usually includes something like double-buffering to ensure a smooth display, but at the cost of some extra latency. This is basically a consequence of how modern operating systems are designed - it's nothing specific to Construct or web technology.

    The only way to display something truly at the mouse cursor position with no delay is to set the cursor image as R0J0hound suggested. Anything else at all on the system will be subject to latency.

  • My workaround was just to hide the cursor entirely, so it doesn't feel perceptually bad or laggy. Seems to work well enough.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)