+4 votes

the docs dont explain it very well

in Engine by (386 points)

1 Answer

+8 votes

In Godot 3, modulate is a property. You can set it from a script by writing modulate = Color(0,1,0). There is no example of how to set it because we would have to write one for every single property of every class, so instead you should learn how properties work. They are just like variables that have internal getter and setters (so you can use set_modulate(Color(0,1,0)) too) but it's just easier to use the property shortcut.

Example 1:

extends Sprite

func _ready():
    modulate = Color(0,1,0)

Example 2:

extends Node

func _ready():
    # If MySprite is a child
    get_node("MySprite").modulate = Color(0,1,0)

Note: in Godot 2 properties did not exist so you could ony use set_modulate or get_modulate.

by (27,497 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories