Physics behavior not paused when object time scale = 0

0 favourites
  • 14 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Problem Description

    When the system event "Set object time scale" is set to zero for an object with the physics behavior (ALSO the Sine Behavior is not affected) the object still falls because the physics behavior is not affected.

    ** Note to devs: I thought we figured out how to fix it below, but then I found that if the solution (change to Framerate Independent mode) is applied to a sprite that isn't the first then the fix has no effect!!! So there might still be a bug here...

    Attach a Capx

    Done

    Description of Capx

    Press Right arrow to cause the physics object to fall off edge. Press space to see that the fall continues despite object time scale set to zero. Refresh and press Right to fall off edge again and press Ctrl to see the object stop falling when the entire system time scale is set to zero.

    Steps to Reproduce Bug

    • Use the physics behavior on an object.
    • Put the object in a state of physics movement (falling)
    • Set object time scale to zero.

    Observed Result

    Physics behavior continues to operate.

    Expected Result

    Object to pause

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (don't know)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    Windows 7 SP1

    Construct 2 Version ID

    Release 168

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There's nothing wrong. Setting time scale to 0 has no effect on physics in motion. I had the same issue in a game. If there is a way to pause an object n motion with physics, I'd like to know it.

  • Use the system event "set time scale" that pauses physics objects in motion, but it pauses ALL objects at the same time.

    You can also use the physics event "disable" to turn physics behavior off and the object will stop dead in its tracks.

  • When I use System time scale, doesn't work either. I never thought of disabling the physics. Thanks!

  • Setting system time scale to zero definitely works... that freezes everything in the game... it is how Scirra examples show how to implement "pause" in a game.

  • When I use System time scale, doesn't work either. I never thought of disabling the physics. Thanks!

    If you look at the capx that I attached to this bug report you will see by pressing Ctrl that the system time scale gets set to zero and the physics stop.

  • If you set the physics stepping mode to 'Framerate independent' then you can set the object time scale.

  • If you set the physics stepping mode to 'Framerate independent' then you can set the object time scale.

    Awesome answer Ramones!

    I have attached a new capx that uses your suggestion and it now works!

    It is not working in my game for some reason, but since this sample capx works it must be due to some other logic in my game... more work to do.

    Thanks for the answer to this problem!

  • *** I just noticed something though... in the FIXED capx I added a second physics sprite... it pauses also even though I am not settings its time scale at all? How can that happen?

  • Ok so now I uploaded another capx "BrokeAgain" version...

    This one just applies the "Fix" to the second physics sprite called "Box" and now the pausing has no effect again... strange.

  • Closing as not a bug: it is documented that the physics behavior by default ignores dt unless you set it to framerate independent mode, and changing the timescale only affects dt.

    The 'framerate independent' mode is not designed to be changed at runtime. If you still think there is an issue please report it only using one setting set on the start of layout.

  • The 'framerate independent' mode is not designed to be changed at runtime.

    Because of that statement I suppose it is not a bug... however you might want to add that support because of the root reason where I was trying to pause individual objects at run time.

    I am sure you have seen in the forums people talk about how to pause the game yet still have menus, dialogs, and other UI that takes full advantage of the C2 engine while the game itself is paused in the background.

    This is exactly why I am changing the 'framerate independent' mode at run time. I want my physics objects to be as accurate as possible yet be able to pause them without setting the system wide timescale to zero which prevents my menus from using things like the "lite tween" plugin to implement "touch scrolling lists with momentum".

    I have this working now because I can change the 'framerate independent' mode at run time but it seems that I have to set it on the first? physics object I added to the layout and then it applies to all the physics objects. So I have a function that does it to each physics object type in the layout so that it happens to hit whatever the first one was on that layout whenever I pause the game... this works, but apparently isn't designed to work according to your statement.

    Let me know if I can help you in anyway (sample capx) if you are interested in adding this feature to allow people to pause the "game" but not the menus that popup during the paused game.

  • Setting the framerate mode is not a suitable mechanism to implement pausing. Either use framerate independent mode and it happens automatically, or disable the behaviors when pausing. If you think there is still a problem when not changing the framerate mode at runtime please make a new report.

  • Setting the framerate mode is not a suitable mechanism to implement pausing. Either use framerate independent mode and it happens automatically, or disable the behaviors when pausing. If you think there is still a problem when not changing the framerate mode at runtime please make a new report.

    1) The documentation says that the Framerate Independent mode isn't as accurate as the other mode. How much difference do think it really makes?

    2) Disabling the physics behavior doesn't work (I tried it) because for example if the player, which has the physics behavior, is in the middle of a jump and I disable the behavior to pause ... when I unpause and re-enable it then the player just drops straight down instead of completing the jump. If I flip from Fixed to Frame independent mode when I pause and then back again when I unpause then the physics calculations continue where it left off when I paused and player completes the jump.

    I am "tricking" C2 into freezing only the player, enemies, moving platforms, and other "play time" game elements (even physics behavior objects), yet still allow full C2 functionality during the "pause" for the game menus, dialogs, etc... I have tried all kinds of different ways to do it without causing some negative side effect (like #2 above), but the only way that works is 1) Disable Sine behaviors, 2) Set ALL physics objects to "Framerate Independent" and time scale to 0, and 3) disabling all events directly related to updating "play time" objects.

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