Ideas For Hype 5 Features…

I think the phantom energy loss problem is fixed. :smiley:

I did a livestream on YouTube until the problem was fixed. The Physics engine did not need modification. Basically, the solution involved testing the suggestions here… https://github.com/liabru/matter-js/issues/256#issuecomment-847300752

There were three changes that did it…

  • Set the body inertia to “Infinity”
  • Set the slop to zero (0)
  • engine.positionIterations = 20;

Here's an example of indefinite bouncing working…

index.html.zip (1.1 KB)
(Matter.js not included. It's over here… https://raw.githubusercontent.com/liabru/matter-js/refs/heads/master/build/matter.js

The problem is that I couldn't get… engine.positionIterations = 20 …to work with Tumult Hype. I don't know where to set that value. :man_shrugging:t2:

All three of the changes were needed to add indefinite bouncing… slop = 0, inertia = Infinity, and engine.positionIterations = 20.

So, I think this is a great upgrade idea for Hype 5. An issue that is nearly 10 years old on GitHub seems solvable and the Physics features in Hype can be improved dramatically with the following…

Physics Improvements For Hype 5

  • Add finer control of Physics bodies
    • Inertia… especially the “Infinity” value
    • Slop
    • frictionStatic
    • isSensor
    • sleepThreshold
    • timeScale
    • (Basically review the docs and add what could be useful. Don't oversimplify it!)
  • Don't round values in Hype's Physics fields (Let us be precise without JavaScript)
  • Add greater Physics engine controls
    • engine.positionIterations <-- Important!
    • engine.velocityIterations :zzz:
    • engine.enableSleeping :sleeping_face:
    • Matter.Resolver._restingThresh
  • Update Matter.js to the latest version <-- Very Important!
  • Improving the Hype JavaScript API in order to make it easier to modify Physics settings — Essentially, it's like adding the Photics-Physics-Bridge, but native to Hype.
  • Debug Mode
    • render.options.showStat
    • render.options.showPerformance
    • render.options.showIds
    • render.options.showSleeping
    • render.options.showVelocity
    • render.textures
    • render.options.wireframes
    • render.options.wireframeStrokeStyle

The reason for Debug mode is so that people can easily see this data. I knew the problem was fixed when the console log constantly returned… {x: 0, y: 10.277777777777551} …as the velocity during collision start.

Essentially it's a tradeoff of performance vs accuracy… https://brm.io/matter-js/docs/classes/Engine.html#property_positionIterations …The default value is "6", but it's been almost 10 years. Computers are way more powerful now. That's another reason for adding the “Debug” mode. Let people do performance testing in their game, so they can adjust the Physics settings as necessary.

This is huge!

By making these fairly minor changes / additions, it addresses two major issues with game development and Hype. The CCD issue is improved with the newer version of Matter.js and these additional Physics settings resolve the energy loss issue.

While the API should be expanded to allow for easier management of Physics settings, the Hype app itself should also be updated to allow for more control over the Physics engine. I know Tumult is hesitant to do things like that, as it makes the interface cluttered, but this could be a winner!

This still needs testing and work, but I suddenly feel it might not be necessary to switch the Physics engine.

1 Like