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

Discussion in 'BBNodes' started by Ivan Perfetti, Jan 11, 2021 at 4:10 AM.

  1. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    109
    Likes Received:
    114

    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 at 4:27 AM
    Jackazoid, Sean Buildbox and viking like this.
  2. viking

    viking Avid Boxer

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

    Ivan Perfetti Avid Boxer

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

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    109
    Likes Received:
    114
    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.

Share This Page