Delta Time keeps updating when timescale turned to 0 by gamepad input

0 favourites
  • 3 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Problem Description

    I am in the process of adding gamepad support to my touch based game KlangM. I've come across an issue with my game's pause feature. I pause my game by turning the time scale to 0, relying on that all following delta time expressions will return 0. This works as intended when pausing through a touch or keyboard input. The following delta time calculations return 0.

    However when the pause is performed through a gamepad input, the delta time value reported the current tick isn't 0 even with the timescale confirmed to be 0.

    This messes with a lot of carefully laid out game logic. While I can work around this by switching event 1 and 2 around in this isolated capx, that isn't doable in my main project. Is there an easy fix for this?

    Attach a Capx

    Description of Capx

    Blank layout with a text object displaying the current time scale.

    3 events:

    1 - Hit spacebar, tap/click or press a gamepad button to turn the time scale to 0. Effectively pausing the game

    2 - Adds dt to timescale and updates the text object with the current value

    3 - Hit return key to reset the time scale to 1

    Steps to Reproduce Bug

    Push space or tap/click. See that the time scale is permanently set to 0.

    Push return key to reset the scale to 1.

    Push any gamepad button. See that time scale is set to 0, but will continue to rise back to 1. This breaks my game's pause logic.

    Observed Result

    Delta time works as expected with touch and keyboard input, but not with gamepad.

    This happens in all browsers.

    Construct 2 Version ID


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Its not bug, its your events that causes this behavior. While space and touch update timescale when clicked. Gamepad seems to update end of event logic. So your expression clamp( timescale+dt, 0, 1 ) will just keep dividing 0.01666 with itself again and again. So put controller logic after that clamp or redo your clamp event

  • It's not a bug, you just have a dependency on the order of events. Some triggers fire at different times, and the gamepad trigger can run just before "every tick". In this case dt is still a nonzero value (because dt doesn't change during ticks), and the "set timescale" action in the "every tick" event will override the previous one.

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