How to apply a shader locally to only one instance of a Sprite?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Diet Estus

I have an enemy with this structure:

 KinematicBody2D
    > Sprite
        > AnimationPlayer1
        > AnimationPlayer2
    > Other stuff...

The second AnimationPlayer animates some uniforms in a shader attached to the Sprite. It create a dissolve effect when the enemy dies.

Unfortunately, whenever one enemy dies, the shader animation initiates, and all of my enemies dissolve, rather than just the one I killed.

How can I fix this?

:bust_in_silhouette: Reply From: kozaluss

In You shader parameters there is a checkbox “local to scene” or similar - check it and it should solve the problem.

I can’t seem to get that to work. I am using a TextureProgress node instead of a sprite node because I am applying a shader to a health bar in my project, so I’m guessing that’s why. I just wanted to make sure though.

Typical_Hyrule | 2022-07-21 16:17