unity-game-engineshaderspritesprite-sheetshader-graph

Basic twirl shader 2D pulls other sprites in spritesheet


I've been trying to achieve a basic twirl shader effect and I'm pretty close to achieve it. I'm new to shaders and dont understand what's going on here.

I have a spritesheet with several characters, example below:

Spritesheet

And I created this twirl shader:

Shader graph

It kinda works, but when applying the twirl the other sprites appear in the effect because they are in the spritesheet. In the example below you can watch the sprite being "twirled" (and the center point is not right) and then another sprite appears.

enter image description here

Is there any way I can do this without having to export the sprites and create a material for every single enemy? And center correctly the twirl effect?

Thank you for helping!


Solution

  • I'm not sure which Unity version you are using but this was discussed in the forums for a while and the Unity team actually decided that this behaviour is by design (at least for 2019 and 2020), as you can see in this link.

    Even though you might lose optimization when dividing the sprites into seperate files, I think it would be best to do just that.

    There are some hacky solutions that work in some cases, so you can try them out depending on your project.