Modulating object problems?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lincolnpepper

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:

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.

:bust_in_silhouette: Reply From: kidscancode

The Color constructor expects float values between 0-1.

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

Also, your code could be simplified:

if gold:
    modulate = Color8(244, 253, 21)

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

lincolnpepper | 2018-04-24 21:15

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

kidscancode | 2018-04-24 21:18

oh, nice to know.

lincolnpepper | 2018-04-25 02:27