There’s no method to change the color, but there is a property in the D2dDestructible script called ‘Color’ that allows you to change it. Does PlayMaker not have the ability to call properties? If not, I can add a method to do this.
To change the color of your object each time it gets hit, you first need to write a script (or PlayMaker FSM) that has this feature. You can then use the D2dCollisionHandler’s ‘OnImpact’ event to call your color change method (or activate the FSM). To make the color only change after the first split, you could disable the D2dCollisionHandler component, and enable it from the ‘OnStartSplit’ event.
Let me know if you have any issues with implementing this.
I am thinking about buying your extension but I am unsure if it will work in my use case, could you give your opinion?
I am planning a side-view game in which you can mine the ground (think Dungeon Keeper in side-view). Here is an example mock up: 2D RTS concept - Imgur
Is your extension performant enough to support mining like that on a map approx twice as big as a typical Worms map with about 20 AI agents + several NPC characters? What should I keep in mind when tuning for performance?
In your mockup, it looks like the level is made from blocks with rounded edges. In this scenario it is best to use a tilemap system, because that gives you very fast digging speed, rendering fidelity, and AI performance, but of course it limits you to blocks. Destructible 2D is more useful for games where you can freely dig or destroy scenes/objects. You can also combine the two, for example the tree in your mockup would look bad if it was cut down using blocks, but it would look good with Destructible 2D, so you could simply place this on top of your grid tilemap terrain.
Elaborate shapes like this aren’t an issue for Destructible 2D (after all it is pixel based destruction), but doing it on this scale with such high detail may not be possible on most machines, not to mention the pathfinding code would have to be done by you from scratch. A scene very much like that could probably be done with a good tilemap though, it’s not like each tile must be on or off like in minecraft.
You can slice down to 1 pixel, but if your slice is rotated then 2 pixels would probably give you better results. Just keep in mind the actual size of 1-2 pixels depends on the resolution of your textures relative to their scale.
Can someone give an hint how to create an alphatex? Adobe Illustrator is fine for this?
I need to create an AlphaTex that is a combination of the AlphaTex of two different images, just like it is done in the Animation scene (Bee and Bee Flap are combined).
The bee AlphaTex was created by loading the first frame, then loading the second frame on top of the first on a separate layer, then saving them together as a single png with transparency. I also stripped the RGB channels, but this isn’t required, or you can do this via the Unity texture importer by making the image single channel/Alpha 8, then just drop it into the Replace → Alpha With.
I forgot to mention that the Bee example uses the ‘Keep Alpha’ shader/material. This shader combines the alpha of the AlphaTex and the current MainTex, which should avoid the issue you see there. Simply select the MeshRenderer for your snake and change the Material → Element 0 to ‘Keep Alpha’ and it should work.
P.S: How should I setup the alphatex using the code? If I try to call function ReplaceAlphaWith, it expects a strange type named D2dSnapShot and if I declare a public D2dSnapShot member I cannot drop my AlphaText on it.
Are your snake sprites different sizes? If so, one will stretch/shrink when it gets changed, causing the issue you see there. Make sure the source images are the same size, and the sprite rectangle itself is exact the same, like the bee ones.
ReplaceAlphaWith has five overloads, the snapshot one is just the first. You probably want: ReplaceAlphaWith(Sprite sprite)
However, I recognized that when I have multiple sprites overlapping each other, and if I set the stamp size to x=3,y=3 it takes about a second to perform the action. I tried to scale the stamp to x=5,y=5 and it became even worse.
Is the performance issue because of the scaling (say if I would use a larger texture for stamping and scale it to x=1,y=1 would it increase performance)? Or is it because of the amount of pixels being stamped? Or is it because there are multiple colliders being stamped?
How can I increase performance best?
Make 1 sprite out of the complete level (terrain)?
Last time I profiled the code, I found that damaging overlapping sprites was slow simply because of the amount of colliders that need updating, so to optimize it you’d have to reduce the AlphaTex resolution, simplify the colliders, or prevent them from overlapping as much. I can check the code again though.
Changing the scale for the same visual result won’t change anything, as you’ll still be modifying the same amount of pixels.
I just bought the Destructible 2d plugin. I am creating a sprite with this tutorial:
But the version that I have looks a little different, and in the D 2d Destructible script I don’t see a collider type. How do I make the sprite a collider without this option?