#tried to impliment hit flash, now the sprite is just continously white

1 messages · Page 1 of 1 (latest)

urban crescent
#

players on the left, here is the shader
shader_type canvas_item;

uniform bool enable_white = true; // Boolean variable to enable/disable effect

void fragment() {
vec4 current_pixel = texture(TEXTURE, UV);
if (enable_white) {
// Set the output color to white
COLOR = vec4(1.0, 1.0, 1.0, current_pixel.a); // RGB and Alpha
} else {
// Keep the original color
COLOR = vec4(current_pixel.r, current_pixel.g, current_pixel.b, current_pixel.a);
}
}

this enable_white is off by default for all the players

#

damn shaders are annoying

sonic wadi
#

You might not need a shader for this

#

If you set the Modulate value of a node to have really high values (instead of being within the normal ranges for colours), you can kind of force the whole sprite to turn white

urban crescent
#

if i knew 3 hrs before i would have saved 2 of them

#

even when i turn it off, it comes on automatically if i switch scenes somehow

sonic wadi
#

I'm not too familiar with shaders, but if it's a problem with GDScript code I can try to have a look

#

Though

#

Actually I really shouldn't it's 1am I need rest

urban crescent
#

yeah sleep is important

plush oriole
#

You see, material / shader is a resource and resource is shared over all instances that use it

If you want shader to affect only one object, you need to make it unique to scene
But the you lose the shared behavior (that is helping performance)

So your options are

  1. Go on make material local to scene anyway since usually that doesn't matter performance wise
  2. Make a new flash material and slap it to material override slot to display flashing effect, set the slot to null again to remove flash effect
urban crescent
#

either way i tried it out after i somehow got it working and felt it was kinda wierd

#

so i removed it

plush oriole
#

I know it feels weird. But it works. And we can share materials across instances. So I leave it be

urban crescent
#

like i realised i didnt really want it

#

i might impliment screen shake some time in the future though

#

so it feels more responsive