0 votes

I have asteroids that i want to be able to turn to a gold color by turning a boolean "gold" to true. I have the current line in the ready function:

if gold == true:
    set_modulate(Color(244,253,21))

But for some reason this makes it completely white, which doesn't make sense because if i just change the modulation to these values it works fine. Anyone know what's going on? I used print and i found that it does recognize modulate with these values but it still doesn't turn it gold.

in Engine by (243 points)

1 Answer

+3 votes

The Color constructor expects float values between 0-1.

If you want to use 0-255, use the Color8()GDScript function.

http://docs.godotengine.org/en/latest/classes/class_color.html
http://docs.godotengine.org/en/latest/classes/class_@gdscript.html#class-gdscript-color8

Also, your code could be simplified:

if gold:
    modulate = Color8(244, 253, 21)
by (20,923 points)

Oh yeah, thanks! And thanks for teaching me about the Color8 type, that's helpful.

To be precise: Color8() is not a type, it's a GDScript function that returns a Color object.

oh, nice to know.

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.