This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

How would I gradually redden a sprite based on health?

CodeNoEvilCodeNoEvil Posts: 1Member

A variable can be declared as uniform. In this case, its value will come from outside the shader (it will be the responsibility of the material or whatever using the shader to provide it).
Functions can’t access uniforms or other shader variables.

Given that I want to have an enemy with health, and as the health percentage gets lower the enemy changes color to a more red version. I understand how to set a color in a shader, but how is it supposed to work if functions can't access variables!

Any examples or links would be great!

1) Enemy flashes red when hit and color turns back to main color.
2) Enemy color darkens the more damage taken.

Best Answer


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.