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_modifier: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:
Here is the code when the enemy takes damage:
func take_damage(amount:int) -> void:
hp -= amount
animation.play("Hurt")
velocity.y = -150
await animation.animation_finished
if hp <= 0:
kill()
I have no idea what is going on...