Why my shader animation is playing on 2 separate nodes?

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

So… Basically, I have a AnimationPlayer node in my enemy scene.
I use this shader to make the sprite blink:

shader_type canvas_item;

uniform vec4 flash_color:source_color = vec4(1.0);
uniform float flash_range:hint_range(0.0, 1.0, 0.1);

void fragment() {
    vec4 color = texture(TEXTURE, UV);
    color.rgb = mix(color.rgb, flash_color.rgb, flash_modifier);
	COLOR = color;
}

Then, the AnimationPlayer node modifies the shaders parameters in the animation. the animation works fine when there is 1 enemy instance on screen, but if there is more… this happens:


As you can see… When only one enemy takes damage, the other one also plays the shader, but not the whole animation.
This is the animation tracK:

I have no idea what is going on

:bust_in_silhouette: Reply From: woyosensei

How do you spawn enemies on the scene? If you duplicate them with Shift + D then the copy takes material from the original which cause that effect. If you want to avoid it make material on each enemy unique or spawn them via code.
I’m not sure if that’s exactly the right way but should help or at least give you a hint into right direction.
BTW nice art there :slight_smile:

The copied material stuff is correct. I found the anwser, just set the resource as “local to scene” :slight_smile:

Ly97 | 2023-04-10 21:42