• Unity
  • I made an animation of a character disappearing in Unity.

Hello.

I made an animation of a character disappearing in Unity.

However, when it disappears as shown in the picture, each part merges and disappears.

The image on the right is a sprite.

I want to make the skeleton file disappear like the sprite on the right.

I've been scouring the forums and trying to find related content, but I don't understand it at all.

Because I'm learning Unity, and I'm an animator, not a programmer.

Are there any related videos or articles with detailed information on learning?

You will probably represent it in games like the one on the left in many projects.

I hope there is a good solution for this.

I've searched for everything that comes up, but I can't find a solution because it's difficult. 😢 😢 :tear: :tear: :tear: :tear:

Related Discussions
...
  • Изменено

This is a pretty common question and unfortunately the solution isn't simple. When you set the alpha/opacity in Spine, it is applied to each of the 'attachment images' that are rendered. So if you set the alpha/opacity to 50% for the entire skeleton, then the places where pieces overlap will not be overall 50% opacity, since it will have rendered multiple images (with each individual one having 50% opacity) on top of each other.

Here is a ticket with more info - the usual solution is to render the spine character to a RenderTexture at full alpha/opacity, and to then render that RenderTexture 'to the screen' at whatever alpha/opacity you desire.

https://github.com/EsotericSoftware/spine-runtimes/issues/1337

At the bottom of that ticket there is some code for doing the RenderTexture technique. I haven't tried it myself but maybe you could give it a look. Note that if you aren't a programmer and/or don't have experience with this sort of stuff, it may be difficult to implement. I'm not sure how 'out of the box' that code snippet is.

I tried applying the above github code, but it doesn't work. 😢

https://tsubakit1.hateblo.jp/entry/2017/11/25/200555
There is also a method like this. Could this method be useful for spine as well?

gunspike написал

https://tsubakit1.hateblo.jp/entry/2017/11/25/200555
There is also a method like this. Could this method be useful for spine as well?

They are rendering the character from the closest attachment-image to the furthest, and setting the stencil (mask) as they go, so pixels for any attachment-images that are 'underneath' an already-drawn pixel won't be drawn. Pretty interesting, but like they mentioned in their post, there are a lot of possible issues when using that technique. One major limitation would be that it wouldn't support transparency in the individual attachment-images themselves. The way the Sprite Mask works is that it sets the stencil (mask) for that pixel IF the alpha value of that pixel is above a certain threshold. So it would work fine for characters where all of their pixels are fully-opaque (like pixel art), but if you have images that have varying levels of alpha/opacity, it isn't going to work well with the Sprite Mask. Imagine a glowing orb image that is fully opaque at its center and pixels get less and less opaque as you move from the center. There will be a hard cutoff point based on the Sprite Mask's alpha threshold value where the mask will no longer be set for the pixel.

So to wrap things up, that technique COULD work, but it depends on your art style (pixel art? or art with soft edges and transparency?), and your project's perspective/view (look at the other issues that are mentioned in the post, like overlapping multiple characters, and the sorting issues, etc). I wouldn't use it personally.

wow thanks for the detailed reply. 😃

The above example is possible, but it means it's not good for project management!

Then the method is only possible with the method mentioned in the last thread.

I think I need to study render textures quickly.

I would be grateful if you could explain in as much detail as possible an example where there is a solution for this in Esoteric Software and how to do it! 🙂

This is written by a translator, so it is not smooth. Please understand.

gunspike написал

I would be grateful if you could explain in as much detail as possible an example where there is a solution for this in Esoteric Software and how to do it! 🙂

I don't know of a specific example/tutorial of using a Render Texture with Spine. If you want to try to figure it out, you can research how Render Textures work and look for any generic tutorial, and then apply it to your Spine characters. But like I mentioned earlier, using Render Textures isn't a particularly easy thing, so if you don't have any knowledge about the rendering process / cameras / etc, it will probably take some time and research.

A new example component SkeletonRenderTexture has been added to the repository on the 4.0 branch, alongside with a fadeout example scene named 'RenderTexture FadeOut Transparency'. This commit will be merged to 4.1-beta soon.

A new 4.0 spine-unity unitypackage is available for download here as usual:
Spine Unity Download

wow!! Thank you so much Harald.

You will be really blessed.

thank you. :lol: :lol:

Glad to hear it helped! Thanks also go to github user Elringus, who shared his existing code at the github ticket mentioned above that really helped the above implementation come to life - it saved a lot of time of searching the Unity API reference pages 🙂.

Thank you Harald.

The sample works in version 4.0. thank you.

However, I am still using version 3.8.

Could you please upload that sample to 3.8 unity?

I copied and pasted version 4.0, but it doesn't work in 3.8.

What does "not work"? Please always describe in detail what error messages you receive, what you expect to see and what you see instead. Otherwise it's like telling a doctor on a phone "it hurts", which will also not be enough to diagnose the situation.

I have set up different projects in Unity.

One, when I opened the sample project file of Unity Runtime 4.0 version, the render texture fade out worked well.

Another thing, when I opened the file in the Unity Runtime 3.8 sample project, the render texture fadeout did not work and the following error was sent.

Assets\Spine Examples\Scripts\RenderTextureFadeoutExample.cs(40,10): error CS0246: The type or namespace name 'SkeletonRenderTexture' could not be found (are you missing a using directive or an assembly reference?)

I copied the script along with the sample scene.

This looks as if you didn't copy the SkeletonRenderTexture.cs file (the important one), but only the RenderTextureFadeoutExample.cs file (the minimalistic script that just shows how to use the SkeletonRenderTexture.cs file in the example scene).

thank you.

I'll test it again and post a video.

overwhelming gratitude


harald

The test was successful.
Thank you very much.

Now I want to actually use this script in my game.

what will you use it for

When a character dies, I want it to fade out and disappear.

I want to apply it using the script used in this example scene.

I have no idea what to do.

  1. Do I have to set the alpha value separately for the animation where the character disappears from the game?

  2. Or should I use this script to have this event be used for a specific event?

  3. If you play it, it disappears and reappears, but what if you want it to disappear only once?

Sorry for so many questions. But Harald's answer will help many game makers, and animators won't struggle.

Thank you very much. esotrick software

Admittedly the example scene and component was rather minimal and perhaps a bit hard to read. I have now added a SkeletonRenderTextureFadeout example component, and improved the documentation at all related components. The example scene has also been updated to use the new component. It's now quite simple to use and should be easy to understand: attach both components, disable both. To start the fadeout, enable the SkeletonRenderTextureFadeout component.

New 4.0 and 4.1-beta unitypackages are available for download here as usual:
Spine Unity Download
Make sure to copy all 3 fadeout-related components and the example scene to your 3.8 project.

Thnak you sir! 😃

I hope it helps you and other users, it should be quite easy to use now. 🙂

12 дней спустя

I just wonder, how does the Unity's CanvasGroup work so well with other Image objects stacking on each others. Is it also using RenderToTexture to fade them all together?

Likely, yes. A frame debugger might show what it does. If anyone however finds a new magic alternative, please let us know :nerd:.