@grazer physic swap

ok so wgat if in the code,there was a way to change a objects physics MID GAME so you can go like; theres a plat form and every ten seconds the platform gose non solid then another ten secs and its solid again!

1 Like

You can do that with enable

3 Likes

That was just an example though. This idea actually seems interesting, despite the chosen example being fairly lackluster.

1 Like

Despite enabling and disabling already existing, I agree: Important Block To change flowlab: Hitbox - #11 by Galactian

So some basic physics & material properties can be changed while the game is running, but due to the architecture of the physics engine the shapes are static. It’s what is called a Rigid Body simulation (Rigid body - Wikipedia) which means by definition the shapes cannot shift or deform.

Now, shapes can be removed from the game (e.g. destroying an object) and added (spawn/emit), so in order to change an object from e.g. a rectangle to a circle, the engine would have to:

  1. destroy the old physics body
  2. calculate a new shape
  3. spawn a new physics body with the new shape in the previous position

This is completely doable, but there are two kind of glaring issues with it:

  1. It would be relatively slow - not terrible, but not something you would want to do a lot
  2. It could create situations where the new shape doesn’t fit where the old shape was, and the simulation could become unstable

Anyway, this might be surmountable, but there is a bit more involved than just “changing from one shape to another”, unfortunately.

4 Likes