Godot Version
4.1.1
Question
With the tween function I am interpolating colors to a sprite. The problem is that when I want to change to the green color and it was previously changing to red without the animation ending, the green color is interrupted and the sprite changes to red.
Code:
func _process(delta):
if Input.is_action_just_pressed("ui_left"):
$Label.text = "Change to RED"
ChangeColor(Color.RED,2.5)
if Input.is_action_just_pressed("ui_right"):
$Label.text = "Change to GREEN"
ChangeColor(Color.GREEN,0.5)
func ChangeColor(color,timex):
var t = create_tween()
t.tween_property($Color,"modulate",color,timex)
I assume this is because the previous animation is still in progress and once it finishes, it replaces the current animation.
How can I solve this problem?