Page 1 of 1

[Mod] Interactive Physics (out of alpha!) [physics]

Posted: Tue Feb 19, 2019 00:29
by sorcerykid

Interactive Physics Mod v1.1
physics (by sorcerykid)

Interactive Physics is a completely Lua-driven physics simulator and API for Minetest, offering a far more immersive gameplay experience with plug-and-play integration for new and existing mods alike.

The library handles quasi-realistic physical interactions between entities vs. players and entities vs. nodes (including air and water) -- sufficient to suspend disbelief for purposes of gameplay, but also with minimal performance costs incurred. It takes advantage of several features made available by PR #9747.


Here's a demonstration video showing what is possible:

Showcasing Interactive Physics Library in Minetest

Besides the API, a control panel interface is available to manually override the physical properties of solid and liquid nodes as well as entities directly in-game.


Download Archive (.zip)
Download Archive (.tar.gz)


Minetest 5.3-dev patched with PR #9717


ActiveFormspecs Mod by sorcerykid (optional)
Configuration Panel Mod by sorcerykid

Source Code License:

GNU Lesser General Public License v3 (LGPL-3.0)

  1. Unzip the archive into the physics directory of your game
  2. Rename the physics-master directory to "physics"
  3. Add "physics" as a dependency to any mods using the API.
Usage Instructions:

Interactive physics supports a wide variety of basic physical properties for entities, liquid nodes, solid nodes, and air nodes. It's also possible to manually override these properties in-game by use of the Physics Wand. Simply point to the respective node or entity and left-click. A pop-up window will appear so that you can make the desired adjustments in realtime.


Of course you can always click "Reset" to revert to the default values. If you wish to permanently change the properties of liquids and solids, then you can do so by editing the physics/materials.lua file.

As you can see, the following nodes have been pre-configured for you.

Code: Select all

return {
        ["group:water"] = { type = "liquid", viscosity = 0.5, density = 0.5 },
        ["group:lava"] = { type = "liquid", viscosity = 0.7, density = 0.5 },
        ["default:ice"] = { type = "solid", friction = 0.0, elasticity = 0.0 },
While it is also possible to configure entire groups of nodes as shown above, the physics wand itself can only override the properties of one node at a time in-game.

To set the global defaults for all liquid and solid nodes, just edit physics/config.lua. This is also where you can fine-tune gravity and adjust the properties of air itself.

Code: Select all

world_gravity = 10
air_viscosity = 0.0
air_density = 0.2
default_liquid = { viscosity = 0.2, density = 0.5 }
default_solid = { friction = 0.5, elasticity = 0.0 }
Note that in all cases, except for gravity, the values must range between 0, for no effect, to 1 for full effect. Avoid numbers outside of this range, otherwise the results will be undefined (and possibly not even supported in future versions).

Now that the basic setup is out of the way, you're ready to integrate Interactive Physics into your own mods! First and foremost, you will need to inherit the BasicPhysics superclass. The best place to do this is within the on_activate() callback of your entity.

Code: Select all

on_activate = function ( self, dtime, staticdata )
	BasicPhysics( self )
Next, add a physics table to the entity prototype. Here is an example:

Code: Select all

        physics = {
                friction = 0.4,
                density = 0.7,
                elasticity = 0.3,
                resistance = 0.2,
You can customize these values to your liking, in much the same way as you did earlier for liquid and solid nodes. However, any such changes will be reflected in all instances of that same entity. For situations where entities must not share the same physical properties, simply add self.physics = table.copy(self.physics) to the entity's on_activate() callback.

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

Posted: Tue Feb 19, 2019 02:43
by TumeniNodes
Very impressive!

This could be useful for projectile flight as well (arrows and spears) possibly even throwing axes and daggers, I think.
The possibilities are flooding the brain right now

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

Posted: Tue Feb 19, 2019 06:44
by Devy
Really great! I've been thinking about how cool some sports mods would be.

Is the code going to be posted here? Or should refer to the Athletics mod? Can you provide links? Testing will go faster if people can play with it!

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

Posted: Tue Feb 19, 2019 17:16
by Hume2
Is it possible to apply the density to all entities, so players wouldn't be able to sink in lava?

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

Posted: Thu Feb 21, 2019 16:47
by aristotle
Great job! :D +10!

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

Posted: Sat Feb 23, 2019 22:27
by Diamond knight
This would be good for a minigames server

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

Posted: Sun Feb 24, 2019 15:30
by Skulls
What do you have your server step set to?

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

Posted: Thu May 14, 2020 22:45
by sorcerykid
I'm very happy to announce that Interactive Physics library is now out of ALPHA at long last. I have been waiting for the buggy collision detection in the engine to be fixed. Thankfully there has been a huge improvement with Minetest 5.2 and 5.3-dev -- enough that I am confident that this library is finally usable.

The relevant PRs that addressed those issues are found here: (just merged today!)

Here is a brief clip showcased Interactive Physics being used in conjunction with my Thievery and Mobs Lite mods. Both the broadhead arrow, the landmines, and the zombie gibs are physics enabled.


The repository has been updated with the latest development build:

The only dependency is ActiveFormspecs. However, it is optional, should you wish to manually override the physical properties of nodes and entities in-game. Otherwise, there are no required dependencies.

Re: [Mod] Interactive Physics (out of alpha!) [physics]

Posted: Thu Jun 11, 2020 18:33
by ErrorNull
this looks awesome. so does your mod allow blocks like dirt and trees to behave and fall with gravity now? no more floating blocks?

Re: [Mod] Interactive Physics (out of alpha!) [physics]

Posted: Thu Jun 11, 2020 18:50
by sorcerykid
Thanks! Dirt and trees are nodes, so they would not be effected unless converted into an object (a-la falling nodes for example).

On a related note, here's a video from a few weeks ago of the "new and improved" athletics mod using the latest version of Interactive Physics. The movement of the soccer ball is much more realistic now :)