Update: New Physics Engine

As part of the move to HTML5, I needed to replace the physics engine with something much better performing in order to run acceptably in Javascript. This update contains that new engine. In addition to significantly better performance, there are a few improvements and new features as well:

  • improved performance
  • scaled collision shapes: Now collision shapes are scaled along with sprite when an object is resized using a Scale block
  • removed 100% limit on scale: Scale block can scale objects up as well as down
  • fixed capsule: Capsule collision shape is now a proper capsule instead of two circles. It fits and works much better than the previous version, but be aware that the size (and therefore mass) is slightly different, so objects currently using a capsule shape may need a bit of tweaking
  • polygon collisions: a new collision shape option. This generates an arbitrary polygon that is the shape of your sprite. Any shape you want! (finally!)
  • density setting: often requested feature - adjust the density of your object to increase/decrease its mass

Also, some bugfixes:

  • spawned objects reset correctly when returning to editor
  • fix class names getting extra numbers appended when not needed
  • gravity settings update without reloading game
  • updating physics settings of one object updates all of its clones

[EDIT]:

  • There is no more Drag setting for objects. I may end up adding a global drag setting, but the new engine does not support this feature on a per-object basis.

I did my very best to make the new physics calculations to align as closely as possible to the previous ones, but it’s entirely possible that I either missed something or messed something up. Let me know in the thread if I broke something in your game and I’ll try to fix ASAP.

My game Guraga is not working now. The enemy’s come way to fast now.
https://flowlab.io/game/play/1055138

Hey Johnny Boy,

I failed to mention that the Linear Drag setting has been removed, which is causing the issue with your enemies. To fix this, do the following:

  1. Edit your enemy object and deselect “affected by gravity”
  2. Add a downward force to make them move, like in the screenshot below

enemy_drop

This will also allow you to fine-tune how fast each enemy moves, so it’s a better solution than gravity/drag. Sorry for the inconvenience.

Dude! This is bloody BRILLIANT!!

mortors X isnt working

Very interesting. I’m just in fear that if I work on something big, then the engine moves to HTML5, the game will be broken.

@CrimsonBlackGames - You’re right, the motor was acting weird. I’ve fixed it, let me know if you see any more issues with it.

@PixelStudios - I can’t guarantee that the move to HTML5 will be 100% flawless, but I think that the most intrusive and riskiest changes (new renderer and new physics engine) are already complete and in place. The switch to HTML5 will now be mostly changes to the build process and website, hopefully.

@grazer looked thru the update, already made a new mechanic for SB3 using it. Thanks!

@grazer during level change the screen flashes white. Hurts my eyes at night. Can we get that changed to black or something?

Ooh neat! I’ve suggested all of these things before and you finally did it. :grin:
Thanks a lot for removing the 100% limit on scaling objects too.

Some small things I want to say:

  1. Polygon objects are always movable for some reason, even if you set it to non-movable.
  2. Why are the physics settings (density, bounce, friction) still those blue wheels? A number box with + and - buttons would be so much better, and is the max limit in density needed too?
  3. Is this forgotten? I expected it in this update. :frowning:
  4. @CrimsonBlackGames What about making the bg color black?

Thanks for the update @grazer :slight_smile:

This is very exciting. Thanks @grazer !! Im especially interested to check out the density adjustments and polygon collisions. Thank you for updating and improving the engine!

@Latif - yeah, some of these updates were way overdue :slight_smile:

  1. I can’t reproduce the Polygon issue you mention. Do you have an example with a polygon set to non-movable, but is moving?

  2. & 3. I didn’t make any changes that required significant updates to the interface, because that would delay this already big update even farther. I have even more features that I want to add (e.g. object collision groups), and changes I want to make, but the engine update itself already took longer than I wanted. I decided I’d rather get the new engine in the hands of game developers instead of taking more time to design and implement ui changes first.

  3. I think he’s talking about between levels, when one unloads but the next one hasn’t loaded. This will just display a blank space (currently white). I’ll look into this one.

Hi please help me!!! Ever since the update the music for my game is completely broken! (That might be because of my 43,743 blocks, though!) Thanks!
https://flowlab.io/game/play/1031394

Also, is there a way to change the Density in-game? Thanks!

Hey @HumbleTumbler - I played it and don’t hear anything wrong with the music. This update shouldn’t have effected the music at all - what sort of issue are you hearing?

Also, there’s no way currently to update the density of an object while the game is running.

The game plays all the kinds of music at once. Thanks for looking into it!

I know i’ve already asked for a lot, but is Alpha changeable in-game as well? I would like to make a Hardmode version of the Brain of Chtulu in Terraria, which turns invisible some times.

PS My glitch with the music is when you summon the bosses. It doesn’t stop the overworld music like it’s supposed to, and the Boss music doesn’t stop when it’s killed, either.

Hey @HumbleTumbler - Please make a new thread for any issues unrelated to the physics update :slight_smile:

Yes, you can change the alpha in game - use the Alpha block in the properties section.

Ok sorry. Thanks for the help!