# How do I make destructible effect!?

1 favourites
• 10 posts
From the Asset Store
A total of 214 high quality and unique magic sound effects suitable for RPG, Battle Arena and more!
• Hello, friends!

How are you?!

#### How do I make a destructible effect (with Physics) for glass?

like this photo:

These Photos For Unity But How can make this in c3 or c2?!

#### Tagged:

• Up! :)

• I'm not an expert on this though, but it seems you need something that 'holds' those pieces together like joints. The physics behavior can do that. There should be C2 or C3 tutorials for joints such as; https://www.construct.net/en/tutorials/physics-construct-forces-7

Then, use a condition, like when it hits something and you set to disconnect the joints (set them 'free') and they should fall on a solid surface.

• Creating an object from many pieces connected with joint will be a difficult task. And the joints may not hold.

It's easier to destroy the original object and spawn a bunch of pieces in its place. Here is a demo:

dropbox.com/s/lyrnh9od24ewsix/Physics_destructibleBlocks.c3p

• So the overall logic would be when a collision occurs see how hard of a collision it was and if it was hard enough break the object up.

Seeing how hard the collision was should be a matter of looking at the difference of kinetic energy (KE=0.5*mass*velocity^2) of the object before and after the collision. You can do that by saving the KE to a variable at the end of a tick to reference later.

Breaking the object up is either done with pre-made pieces or by somehow breaking it up dynamically.

The pre-made pieces way is the more doable approach. There are two ways to do it though.

1. Destroy the main object and create all the pieces.

2. Just have all the pieces joined together with joints which are later unjoined.

There are pros and cons of either. With 1 you’ll need to be able to place the pieces in the right position and angle, as well as set their linear and angular velocity from the original object.

With 2 setting up the joints between the pieces can be tedious, and you’ll need a way to look at all the pieces as a group with events. Also joints tend to be springy, and you may need multiple joints between pieces to keep them from rotating.

Now the fanciest approach would be to dynamically break the objects up as needed. For that we need to be able to change the collision polygon and what is drawn. For c2 you’re out of luck there with vanilla features, but in c3 you can in theory do it with the distort mesh feature. However it wasn’t meant for that sort of thing so some creative use will be needed.

Anyways, using mesh distort as a tool we will want a way to slice a convex polygon into two separate convex polygons. With multiple cuts we should be able to break the objects up. There are many ways we can take the idea from there such as making the breaks originate from the contact points and use voroni cells to change up how it breaks.

Anyways that’s a general overview. There are probably lots simplifications that can be done to make it more feasible.

• Thank's for answer this questions!

I think to joint in physics behavier, but The problem is that for any force in any direction, it must be anticipated, which is a very tedious task...

Thank You Mr

You always offer interesting solutions!

I mean dynamically break...

how do I use mesh distort for this way?! And can you explain more about it?!

Thank's a lot :)

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• So c3 has a feature that can let you distort sprites with a a grid mesh. The cool thing about it is it not only visually distorts the sprites but it affects their collision shapes too, which in turn is transferred to the physics behavior.

Anyways, I finally got a chance to test it and confirm it lets you do that. Next I was able to use that as a tool to slice up physics object. The basic idea is each sprite is paired with an array making up the points of the polygon. From that with some math I was able to divide two polygons into two utilizing a line. The final step was to take that array of polygon points and setup the distort.

Here's the example of it working. drag a line to cut the sprite.

One quirk with the physics behavior that I had to work around was when creating objects you need to disable them for a frame before enabling them again or they will jump. It's been there for ages.

This only scratches the surface, and was mainly just to show how to slice objects up. I could be adapted to do dynamic breaking by running it in a loop where you'd set the line to be random angles from the collision point.

• So c3 has a feature that can let you distort sprites with a a grid mesh. The cool thing about it is it not only visually distorts the sprites but it affects their collision shapes too, which in turn is transferred to the physics behavior.

Anyways, I finally got a chance to test it and confirm it lets you do that. Next I was able to use that as a tool to slice up physics object. The basic idea is each sprite is paired with an array making up the points of the polygon. From that with some math I was able to divide two polygons into two utilizing a line. The final step was to take that array of polygon points and setup the distort.

Here's the example of it working. drag a line to cut the sprite.

https://www.dropbox.com/s/r8lhe8sha0wa33m/poly_split.c3p?dl=1

One quirk with the physics behavior that I had to work around was when creating objects you need to disable them for a frame before enabling them again or they will jump. It's been there for ages.

This only scratches the surface, and was mainly just to show how to slice objects up. I could be adapted to do dynamic breaking by running it in a loop where you'd set the line to be random angles from the collision point.

Thank you Sir

Thats great but It has a bug!

For example, when we cut the shapes into numbers, the pieces of the bond remain suspended in the air!

an Image:

Is this problem solvable ?!

• Possibly. The only physics part I touch is enabling and disabling it for a frame.

Actually, the issue probably has to do when the polygons have an odd number of points. Distort meshes only have an even number of point with the way I’m using it, so it just sets two points to the same spot. Which is probably breaking the physics library’s collision response sometimes.

Edit:

That doesn’t seem to have fixed it. It seems to work fine without the physics behavior. Probably need to debug the polygons. Likely some numeric errors that are cropping up.

This is assuming that the physics behavior, how the collision shape it generated, and how the collision polygon is distorted are working without bugs.

Edit2:

Found it can crash too. Seems to be in the physics behavior. Anyways, best I can do is add code to make sure the polygons are convex and ordered clockwise. Maybe on another date. If it still fails then the issue is out of my control. Guess there’s always event based physics if I can fit it in and get the inspiration.

Edit3:

Can't fix. My code is generating convex polygons. The mesh distort feature also seems to be giving the correct collision shape. The physics behavior seems to bug out sometimes?

• The easiest way is to have your object split into a few sections, then when a hit occurs, destroy that section and create a number of fragments with physics behavior.

Play around with settings, impulse to make it fly around a bit if necessary.

you could also have these fragments pre-created and set to invisible and with disabled physics, then on impact make visible and enable physics

• 10 posts