Toggle cloth/softbody simulation in runtime!

Hey there,

i’m glad to say that it is possible: You can toggle cloth/softbody physics at runtime, even with geometry nodes. I was searching for it and cant find anyone making it, so i’m writing this tutorial.

HOW TO DO IT?

So, it’s just little complicated. Create some mesh, model it as you want, add cloth modifier to it and move it somewhere off screen, that will be our spawner (meshA). than copy it, remove cloth from the copied one and move it where you want to the toggling cloth be (meshB).

Now let’s program it: Add logical nodes to any other object and make it:
When cloth simulation should start (P key), it spawns meshA at meshB transform and hide (remove RB if needed) meshB. When we want to stop simulation(Enter key), we save mesh of spawned object into string variable, than delete spawned object and set meshB mesh to our string variable. Than simply show meshB.
Only error is that it teleports back to the spawning position.

Image below shows simplified nodetree: (SpawnerObj = BakeClothObj = meshB)

Hope it helps someone.

1 Like

Hi, thanks for the inputs. I am a bit surprised the mesh data can be stored as a string and can be retrieved.

In any case, this seems to be hacky way of toggling the simulation. I would recommend adding a global boolean variable in the SoftBody Class, say

public var paused = false.

And then simulating the Cloth/ SoftBody only if tis variable is set to false in the update function.

This can also be made into a simple logic node for pausing the physics simulations. If you are interested in contributing to Armory, this could be a very good starting issue :wink:

Yes, my solution is hacky, I made it and posted here because I needed to pause (stop) simulation, and I couldn’t find any solution on forums. And I am quite new to armory3D, so I started only with Logic nodes. There are lots of logic nodes to get/set RB, but not even one to somehow edit cloth (softbody). In fact, before I discovered Armory3D, I didn’t even know that Haxe exists. So I don’t really think I’ll become Armory3D developer in near future.
By the way, isn’t it that string can hold any data?