Is there a way to remove color from modulate?

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

Hello everyone. I am using a modulate to change the color tint of the enemy sprite. After a timer runs out, I want the sprite to become normal again, removing the color from modulate. How is this done?

func _on_Hitbox_area_entered(area):
if area.is_in_group("Enemy_damager"):
	modulate =

func _on_StunTimer_timeout():
:bust_in_silhouette: Reply From: godot_dev_

You could create a variable to store the original value of the modulate member (suppose we call it oldModulate), and before setting the value of modulate to, save the modulate as so: oldModulate = self.modulate. Then, when the timer runs out, in your _on_StunTimer_timeout function, you could do self.modulate = oldModulate. This would bring it back to normal, and supports the feature to also have a custom modulate before turning red (it might be green, for example, from some other effect before it turns red). You may want to consider using a Tween to have the red color fade out back to normal using interpolate_property using the initial value of and the target value as oldModulate for your modulate property.

1 Like