Any way to "destruct" an object into pieces?

I am pretty sure there is no way by default, but may be some workaround?

Let’s say I have a cave that is closed by stack of rocks/bricks. I have a hit effect on the character that would simulate explosion/force on the rocks and collapse them. Right now I don’t see a way to do that any other way than using number of single rock objects, then manually stack them up to create an obstacle and then disperse them with a hit.

But that is not good way, because for a single obstacle like that, I would have lets say 20 smaller objects. If I have 10 different obstacles with the same logic, then I would have 200 smaller objects just for this and GDevelop doesn’t allow to group and manage objects together so that’s a nightmare :slightly_frowning_face:

In short, how would someone achieve a destruction effect on a wall, rock, wooden door etc…

Well, in general, in Gdevelop there is the creation of groups of objects, it remains only to create a random movement (explosion) event for all objects that fall under the condition.

https://wiki.gdevelop.io/gdevelop5/objects

======================================

Organizing objects into groups

You can organize objects into groups and then refer to all of the objects in that group by a single name.

This makes it possible to create events that applies to lots of objects without repeating events multiple times, increasing performance of your game, maintainability, and readability of your events.

To organize objects into groups:

  1. In the toolbar, select the Groups icon.

  2. Select Click to add a group .

  3. Select the group.

  4. In the Edit group dialog, select the objects to add the group.

  5. Select Apply .

1 Like

I was looking for something more precise in regards of the visuals. Lets say I have a tile that I want to break into 5 pieces. But not just any tile, but a specific sprite like in the screenshot.
Screenshot_6

Program the object and the points inside it, at which your pieces will appear at the start of the game and, at the event, will fly apart.

I can cut it into pieces in Photoshop, then add every piece as a separate object, manually place the objects together like a puzzle so it would look like one solid tile, and then use Explosion effect on hit for instance, and it breaks apart. But as I said I don’t think this is a good way to do it, because the project will be full of hundreds piece objects in the end…

I don’t even know what to suggest, maybe experiments with particles?

Well, in general, in Gdevelop there is the creation of groups of objects, it remains only to create a random movement (explosion) event for all objects that fall under the condition.

Yes, I use the groups anyway. My problem is that you can’t group them visually in the Objects panel of the editor. This way when you have many object it becomes really bad

And if you cheat and make animation? On impact, let’s play your animation on which the objects are destroyed and scatter? Then you technically have 1 object with 2 animations.

Hmm, that is not a bad idea - frame 1 - the obstacle. Then on hit play animation of the obstacle bricks/rocks falling down, then destruct.
Only it would require a lot of extra work to make the animation. :slight_smile:

IDK if this will help. I also don’t know the size or shape of objects. My 1st thought was if they were similar but different colors then you could make them white and then change the hue. You could also use different animations. Just pick matching frames for each piece.

My other thought was to use a tiled sprite for the objects. Just set the X offset. Sort of like a sprite sheet. Note: oddly I don’t think hue or offset have expressions to get the values but you can save the value to a sprite variable and then copy it to the pieces.

The pieces don’t need to be too perfect. If it’s rubble anything close to the same color will do. The same for the collision mask. As long as it’s smaller than the objects, they won’t look like they’re floating.

There’s also masking but I don’t know how resource friendly that would be.

There’s a lot of suggestions in here and I want to loop back to the original question:

If you’re starting with a sprite image, and want to split it apart into multiple slices of the original image, there is no native way within GDevelop to accomplish this.

The closest I can think of would be to have 5 sprites with the various pieces and pin them to one another to approximate having one object.

1 Like

On hit, delete the original sprite. Then create 5 new sprites each representing a debris part.
You can set up an action that they fly away from the position where the sprite was hit, using the angle of the projectile. To spice things up add explosion particles and smoke as well.

2 Likes

Would the object slicer extension from Victris games be of any use?

May be, but I can’t find it anywhere.

Here is what I got so far with animations:
Recording #4

Used Blender for Cell Fracturing of the stone pillar.
Recording #6

create your main object and make its animation lose pieces on every hit, pause its animation and add 1 frame on every hit (or several hit its up to you) and create another object for pieces on main object it does not have to be exact piece but you can shape exact piece and set frame of main object to second object (i suggest make it 1 animation with several frames and set random frame after its created), you can add some particles to make it look better.

Take a look at Juice FX software by codemanu. It’s 10$ on Steam.

Playing around with sliders, you can make an animation that on first hit destroys an object in 5 big pieces. Then another animation, if you hit it again it will destroy object into another 10 smaller pieces and so on… ( if I understood what you need correctly)

2 Likes

Sounded interesting. I bought it but it is not very good for this type of destruction. Still might be helpful for some effects. Great find!

Here is a little better version with animated sprites. Destruction in Blender + simple smoke sprite.
Recording #8

1 Like