# Collapsable buildings in 3D?

4.2.1

### Question

Can anyone help me figure out how I could make collapsable buildings in Godot, similarly to THE FINALS? I figured how it roughly works:
Basically, the way they do it in the finals is by having multiple pieces of wall that have different “skins” based on a health level each wall have and different style. Then they create a structure somehow (the part I’m trying to figure out how to do in Godot) and add up the weight that each pieces have to old up.
When you damage a wall, the skin of the wall changes and then at some point all the wall’s “health” is gone and the wall breaks. Then all the building’s weight distribution is reprocessed from top to bottom. And when a wall has too much weight on it, it break. It can also break by falling from too high.

That’s how they do it, now, how do I create that structure AND have them linked up together to depend from each-other and unlink some walls AND THEN, calculate all the weight stuff? Do I need to create a file with all the building’s design? Maybe I need to use physics joints? Custom resources? The hardest part for me is designing that one physics behavior of linking pieces together and then make them fall together etc…

Also, kinda copy-pasted the question out of my reddit post…

Do you know how to implement a directed acyclic graph? =3
Just kidding, you already have one called the node tree. Make a class, let’s call it “Support”, that has the properties you need, extending Node3D. The bottom and root of the tree should be the floor and it should be indestructible and immobile. Then each child will be a level up in the supports and a level into the tree. (does that sentence make sense?)
When you add an object to the tree, it will be supported by every Support that is its parent.
If you intend to remove an object from the tree, you tell every child to fall. Check for every sibling of the parent to see if they could also support this child (no analogy intended). If they can, cool, reparented. If they can’t, fall and check the next level of parents. Now that the child is reparented we can remove the node that has no health.
You can combine this with RigidBodies to make a physics simulation if you make sure to have free-falling objects parented only to the floor until they are at rest again. Not sure if you want full physics tho?
Anyway, that should be most of what you need. To calculate the pressure you need to have a more complex structure than a tree, but you can fake it by calculating it only on parts that are changing, assuming the ones that aren’t are stable.

3 Likes

Will try it out and see if it works, thx

Still can’t make it work until the next version release because you can’t use CollisionShape3D as a child of another CollisionShape3D… Any tricks?

Make each a RigidBody with a CollisionShape, not just a CollisionShape.

1 Like

Doesn’t work, all the RigidBodies collapse because they don’t maintain each other in place

freeze the rigidbodies until you need them to drop

or something like that

1 Like

That’s not really what I’m looking for… I guess it would be a solution but once you need multiple piece of building to drop together it won’t because they’re considered as separate pieces sadly

i dont understand the problem sorry, all you want to “destroy” must be on separate pieces, by hand or on runtime, but you need pieces

look for the pieces, they simply add a lot of debris and fog to hide the real things
https://youtu.be/eu3gUgZjkmM second 18

they are on runtime reparenting all pieces on same parent, applying the physics to the parent and when needed, remove certain pieces from parenting and applying physics directly to the piece, without parenting, subdividing the whole structure on various parents while changing the pieces for the “destroyed” version of it or removing that piece directly

they are doing a lot of tricks but the principle is exactly the jar

1 Like

Most things in videogames are smoke and mirrors and you gotta learn when you need to be realistic and when you need to not be so it’s cooler. Frozen physics objects are not necessarily frozen forever. You can reactivate them on a collision etc, that’s how the “resting threshold” works. It freezes objects that are barely moving. You can start from a frozen structure and activate only the parts that need to fall. No need for every piece to be fully interactive all the time.

1 Like

I know, I’m just trying to figure out how to reproduce it in Godot… It’s the tricky part. But I guess I need to make my own system that reparents everything. The tricky part is storing each piece’s dependencies

You could also make your own manager class to hold all the dependencies and use static functions to change/poll it so you don’t have to juggle nodes, but that’d mean writing your own tree-diving logic, so YMMV.

1 Like