Changing modulate in editor keeps relative brightness but through script changes all to the same exact color

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

So when i change the modulate of a tilemap through the editor it keeps the relative shades of the colors. So previously white is just as bright and the previously dark greys are just as dark. but when i change the modulate through script it all changes to the same color.

This works correctly for me. What code are you using to change the modulate?

CodeEnder | 2022-11-20 01:04

Just a really simple “get_node(“TileMap”).modulate = Color(x, y, z)” (not exactly this but the modulate changing method is the same)

Nonken | 2022-11-20 03:39

I use Color(String) because it’s easier to copy-paste from color pickers, but if you use the Color(r, g, b) then make sure that the values are fractions, not 8-bit integers (i.e, 0.6 instead of 153). There’s also a button in the color picker that looks like a hashtag that you can click and it’ll give you a copy-paste of the values you need.

CodeEnder | 2022-11-20 04:23

Thank you so much. That was the problem. I had the values set from 0-255 instead of floats between 0.1. Changed them to hexadecimal strings instead and now it works!

Nonken | 2022-11-20 13:15