1 - Yes, 400k AlphaCount is too high for a fully splittable sprite. Do you have a picture of the sprite in question? If it’s something like a level sprite then you could use ‘Local’ splitting, instead of ‘Whole’ splitting, which makes splitting small parts off sprites very fast, but doesn’t work for such large areas. You can also create your object from lots of smaller parts and glue them together, and optimize each part individually.
2 - Fracturing only works on the whole sprite, but if you use ‘Local’ splitting mentioned above, then you can fracture the locally split part to get both fast splitting and fast fracturing of just the split part.
Yes, just remember that if the sprite changes shape then it may not work so well. For example if you have a character walking animation where the arms move, destroying the arm will not cause the arm to be destroyed in the rest of the animation frames, because there’s no way to know what or where the arm is in the other frames. As long as your animation just does minor movements, or changes things that don’t matter (e.g. color) then it should work fine.
Is there some kind of ‘best practice’ regarding sprite resolution and alpha count for (fully splittable) sprites? I was messing around with a 640x640 circle sprite and one 2048x2048 circle sprite. So inherently they have a lot of transparent pixels in the corners. I’ve brought down the alpha count to 15k-ish for both (via Optimize Alpha), but that makes the stamping pretty ‘inaccurate’. By that I mean that the star stamp doesn’t look much like a star anymore with a low alpha count. Between using a ‘low-res’ and ‘high-res’ sprite I couldn’t detect much difference in performance. But when a lot is going on, with a quad fracturer fracturing multiple times quickly after each other, it tends to lag (a lot) with anything that has an alpha count of > 10k-ish. But with a low alpha count the edges look very jagged and not very pretty.
In the Explode-example all the sprites like the fish are around 128x128 which is maybe a bit too low for my taste. But keeping the stamping figure intact, the alpha count needs to be reasonably high… I’m not sure what may cause the lag when stamping, is it rebuilding the collider? I can imagine detecting islands etc is expensive, but it’s also when I’ve disabled splitting, in which case it would only be rebuilding the collider? Typically I set it to size 64 so that should work ok right?
You also mentioned glueing parts together, which I understand. But… When I make a Destructible game object and add a child that is also Destructible (like a building standing on a piece of terrain), when the terrain Destructible is split (either locally or as a whole) it copies the game child object as well. So when the terrain breaks off, the part that breaks off also gets a building of its own So, curious how you would compose such a scene. My end goal is a planet circle sprite with trees etc placed on the surface which can all be stamped/fractured. And in the end upon enough damage the planet should fracture/explode as well, not in 100 chunks but perhaps 20 or so and maybe break a bit when pieces hit eachother.
Sorry for the long post, hope you have some valuable addition to these problems/questions
While optimising the alpha does reduce the resolution of your destruction, keep in mind that it acts as a ‘signed distance field’, so with carefully designed media the destruction can still be quite high quality. Or to put it another way, you should try and avoid using stamps that have a sharp contrast between white and black.
To check performance you can disable colliders, or look at the profiler. But yes, rebuilding colliders is what takes most of the time, alongside splitting.
You can glue a terrain together by making an empty GO and adding a bunch of child destructibles. Since they’re children, any splits won’t cause the others to get modified, though splitting wouldn’t work on the boundaries.
If you have a medium sized planet I recommend you make the planet core solid, but add destructible terrain segments and objects on top. If it’s taken enough damage then you could split the core using some other kind of animation that runs fast. Trying to make the whole thing destructible is probably going to be impractical to optimise to say the least.
Hi there,
I am using the Destructible2D fragment feature, where an object is being dissected. In the editor and on Android devices it all works out fine. But once I run it on a iOS device, something is wrong. The Debugger doesn’t spit any error out. I have the feeling it is the shader Keep-Alpha I am using. But I am not sure what to change.
Do you have any recommendations for the iOS Player Settings in Unity? Like Static Batching, Dynamic Batching, GPU Skinning, Auto Graphics API (GL2, GL3, Metal), etc.
Destructible objects can’t be batched (because they require unique AlphaTex data), so you can set those to whatever you like. The built-in shaders are designed to work with Shader Model 2 and up, so you should be able to use any graphics API you want.
I can elaborate a little bit on the iOS problem I still have:
I fractured one sprite into 3 pieces. And it only shows one of them correctly. The others are just transparent although they should be visible. It works on all Android devices so far (S5, S2), on my Windows laptop in the Unity editor and on my Macbook in the Unity editor. But once I deploy it on an iOS device (iPad 2 for now), it won’t show 2 of the 3 fractured pieces. Any idea? I tried changing to a different Destructible2D Material and Shader. But I went through all of them without any progress.
I sent you an updated Keep Alpha shader that removes some old code.
However, if none of the other materials/shaders work then I’m not really sure what the issue is, as the shader itself is very simple. It’s possible using Metal (if you are) has some kind of issue with the way I update the destructible materials, but I’m not sure yet. I’ll try testing on my iOS devices tomorrow.
Hi there, thanks for the Shader. On iOS devices it now shows the whole object correctly at first, but once it splts into fragments it just splits into exact clones of the whole object.
In the Unity editor it fragments correctly, but looks like this though:
There are some spikes, on the corners which shouldn’t be there.
Also: When I create fragmentable objects that are round (sphere), they appear oval or only a piece of them is being shown. Tested all shaders and materials. (Only iOS devices again, Unity editor and Android works fine)
Hope you can help! Thank you
I tested the latest version of D2D on my iPhone 6 and iPad Air 2 and didn’t notice any issues with the features you described. Can you give me more specific details about your project settings, etc?
I have another small question: I am trying to make a Destructible Object change its color (Mesh Color). But if I change it with an Animator, it remains the same color and won’t change. I figured the Mesh Color ist just being set to the same value (1,1,1,1) back again. How do I manipulate it? I tried changing it in D2dDestructible.Color, but that wouldn’t work either in runtime. Thank you!
You must call the ‘UpdateMesh’ method if you update the color field directly. From code you edit the Color property, which sets the color field and calls this method, but you can’t modify properties from animations.
Hi!
Thank you for great asset! Im really enjoing this purchase
Can it work with playmaker?
Or how can i change color of an object (in D 2d Destructable (script)) on every collision (would be great to filter by tag) but not the first split?
Playmaker can “Call method”, but it needs “Method name” and “Parameters”.
Sorry i cant code yet
Thank you in advance and i apologize for my language.