Fix Slowdowns In Ios & Android Buildbox 3 Games With The Free Dynamic Time Warp Node

Discussion in 'BBNodes' started by Ivan Perfetti, Jan 11, 2021.

  1. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181

    In this clip you can see many cubes (dynamic) being generated in the background and framerate dropping accordingly down to around 20 frames per second; thanks to the Dynamic Time Warp Node the simulation keeps the same speed even if framerate passed from around 60 at startup to around 20 near the end of the clip.
    The two cubes in the foreground (kinematic) show an application of this node to the Move node and the Rotate node, the green one is using updated versions of such nodes, while the red one is using the old Move and Rotate nodes.
    You can see the red cube slows down when framerate drops while the green one keeps moving and rotating at the same speed.


    Download link: https://indym.itch.io/dynamic-time-warp-node

    WHAT'S THIS NODE FOR?

    In short it is a workaround to fix slowdowns in Buildbox games, its purpose is to make games run at the same speed even when the framerate is low.
    It works out of the box for physical (dynamic) objects, it can also work for non physical objects but that's a bit more complex, for more on this keep reading :)

    A slightly longer explanation...
    I was looking for quick ways to compensate for slowdowns in BB, for example when you have many physical objects on screen.
    You might have noticed that in such situations the game slows down, this node is a workaround for this problem.
    This node adjusts time warp dynamically based on current fps; the final result is sort of what you'd get by skipping frames so you might get some stuttering or jerkiness, especially at very low framerates (<20 FPS) but the simulation keeps the intended speed, even if not the same accuracy of course...
    Please note that since it acts on the time warp value it would only work for physical (dynamic) objects out of the box.

    What about non physical objects?
    When you use this node a Setting gets created called Settings.currentTimeWarp.
    This is used to store current time warp value and is updated each frame.
    This value can be use to alter the speed of nodes like the Move node or the Rotate node; you can easily update every node which makes use of the dt value inside the update(dt) function, just like the Move and the Rotate nodes.
    You just have to multiply dt by Settings.currentTimeWarp.
    The attached demo BBDOC includes an example of this, inside the "Move Cube New" object you'll find two modified Move and Rotate nodes.

    PACKAGE CONTENT
    - DynamicTimeWarp.bbnode

    The node itself, just drag and drop it inside an object in Buildbox, it needs to be enabled to work.
    - Dynamic Time Warp Demo.bbdoc
    A demo BBDOC (requires Buildbox 3.3.6+ to be opened).
    - Screenshot & License

    CHANGELOG
    1.0 (January 10, 2021)

    First release.
    1.1 (January 11, 2021)
    Now the node creates and updates Settings.currentTimeWarp to be used gamewide. Updated demo BBDOC.

    License: (Creative Commons Zero, CC0)
    http://creativecommons.org/publicdomain/zero/1.0/
    This content is free to use in personal, educational and commercial projects.
     
    Last edited: Jan 11, 2021
  2. viking

    viking Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    160
    Likes Received:
    77
    You are a Master Jedi
     
    Ivan Perfetti likes this.
  3. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    Ahahahaha, too good you are! :D
     
    viking likes this.
  4. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    I'm going to run some test on an old Android device to check how well this performs there.
    Usually games would run anywhere between 15~30 fps so everything was in slowmotion.
    With the Dynamic Time Warp node game speed is constant even at low fps so it might make it worth publishing games on Android too!
    Stay tuned!
     
    wmfear likes this.
  5. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    I've just tested two demos made with Buildbox 3.3.6 and the the Dynamic Time Warp node on two Android devices, an old and almost dead Huawei P8 Lite 2017 and a more recent Xiaomi 9T and the results are very promising; the test has been conducted also on the Buildbox Preview and on an iPhone 7. I'm going to test on a brand new Xiaomi 10 Lite 5G as soon as I get it on next monday!

    CONCLUSIONS

    FOR GAMES RUNNING CONSTANTLY AT ~60 FPS

    It makes no difference.

    FOR GAMES RUNNING AT 40~60 FPS

    This often is the case in my experience, the Dynamic Time Warp node greatly improves the user experience because there are no more slowdowns; only minimal jerkyness is introduced at 40-45 fps and it is almost unperceivable anyway.

    FOR GAMES RUNNING AT 20~40 FPS
    Buildbox games are usually almost unplayable with FPS between 20 and 40 because the game slows down too much, using the Dynamic Time Warp node makes them perfectly playable since it compensates for the slowdowns; this is true for both iOS and Android of course; using the DTW node introduces some unavoidable jerkyness in movement, especially at very low fps (15-20) but that's not very heavy above 20-25 fps.

    FOR GAMES RUNNING BELOW 20 FPS
    It helps but can't do miracles, most games would be almost unplayable below 15-20 fps in any case.
    Nonetheless using this node would mantain game speed constant and this can be very helpful in time based games or in games with little action where extreme responsiveness is not necessary like in many puzzle games for example.

    DISCLAIMER
    I've tried being very objective during these tests but of course the results are based on my own perception so your experience may vary; please test the node and share your experience, thank you!

    [CHECK UPDATED TABLE OF RESULTS IN FOLLOWING POST]

    Download link (it's free!): https://indym.itch.io/dynamic-time-warp-node
     
    Last edited: Jan 18, 2021
    viking likes this.
  6. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    Last edited: Jan 18, 2021
  7. TheGameAppStudio

    TheGameAppStudio Serious Boxer

    Joined:
    Nov 2, 2016
    Messages:
    927
    Likes Received:
    318
    Thanks for sharing this project. May I know how to activate this node ? is it by attaching the warp node within that blue cube to an existing game character ? Should I click the tick box ? My game character is dynamic and my phone is iPhone 6s .
     
  8. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    Hey @TheGameAppStudio, you're welcome!

    To activate the node you can simply attach it to the Start node in your character or use it inside any other object; you just need a node to be active all the time so the ideal place fot it is inside the character, generally speaking.
    If you don't have a character, like in the demo, you can attach it to anything else, just make sure it stays alive.

    About the tick box, it can be used to ignore the initial time warp value set in world attribute; it is disabled by default since this is probably the preferred behavior.
    An example: let's say you have set time warp to 2 in your world because you want physics simulation to be fast; the Dynamic Time Warp node will consider that initial value and use it as a multiplier so it will try to mantain the same speed; if you tick the box the initial time warp will be 1 and the value set in your world attribute ignored.
     
    TheGameAppStudio likes this.
  9. TheGameAppStudio

    TheGameAppStudio Serious Boxer

    Joined:
    Nov 2, 2016
    Messages:
    927
    Likes Received:
    318
    Ivan Perfetti likes this.
  10. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    @TheGameAppStudio You're welcome! Please share your thoughts about the node to improve it in next updates, thanks!
     
    TheGameAppStudio likes this.
  11. TheGameAppStudio

    TheGameAppStudio Serious Boxer

    Joined:
    Nov 2, 2016
    Messages:
    927
    Likes Received:
    318
    Sure I will :)
     
    Ivan Perfetti and Sean Buildbox like this.
  12. thekebster

    thekebster Boxer

    Joined:
    Mar 31, 2021
    Messages:
    2
    Likes Received:
    1
    Many thanks for making this node! :):D My game has been playing very slow on android. This node has helped a lot but I ran into new issues. I think if I keep testing, I'll finally be able to get a functional game with this node.
     
    Ivan Perfetti likes this.
  13. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    @thekebster Thanks for testing it, I'm glad it helped with your game! :)
     

Share This Page