Change a Color
Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 22 of 28.
Every node that draws has a modulate, a color that tints it. A Color is red, green and blue, each from 0 to 1. modulate starts as white, Color(1, 1, 1), which changes nothing.
The tint multiplies the node's own colors. On something white, you see the tint color. On something blue, a coral tint makes purple.
$Body.modulate = Color(1, 0.78, 0.34) # an amber tintmodulate also tints the node's children. Tint Eyes and both eyes change. To tint a node but not its children, use self_modulate.
Challenge
EasyMake the robot's eyes glow coral.
- In
_ready(), set themodulateofeyes. - Use coral:
Color(1, 0.42, 0.42).
Press Play: both eyes glow coral, and the body stays blue. Then Check.
Try it yourself
extends Node2D
@onready var eyes = $Face/Eyes
func _ready():
pass
All lessons in Nodes and Scenes
Practice on your own: Godot playground