Fade Out
Part of the Game Feel section of Coddy's Godot journey. Lesson 3 of 23.
modulate is a Color with four parts: red, green, blue and alpha (a). Alpha is how solid the node looks. 1 is solid and 0 is invisible.
To tween one part of a property, write the part after a colon:
var tween = create_tween()
tween.tween_property(self, "modulate:a", 0.0, 1.0)"modulate:a" is a single number, so the end value is 0.0. Red, green and blue stay the same. This also works for "position:x" and "scale:y".
A fade is not the same as visible = false. The node stays visible but becomes fully see-through.
Challenge
EasyMake the robot fade away.
- In
_ready(), make a tween withcreate_tween(). - Tween
"modulate:a"to0.0over1.0second.
Press Play: the robot fades out. Then Check.
Try it yourself
extends Node2D
func _ready():
pass
All lessons in Game Feel
Practice on your own: Godot playground