Dynamically Changing Light RGB Values

I just started playing around with Play Canvas and made a kinda creepy test project, but it doesn’t completely work as expected.

https://launch.playcanvas.com/595373?debug=true

Here is the script that isn’t working
https://playcanvas.com/editor/code/541576?tabs=11499664

I expect the r, g, and b values to slowly decrease from 255 until they hit 0, and then go back again, etc., but the color doesn’t change at all :frowning:

Looking at the code, you are not setting the colour of light? You are reading from it but don’t ever set it back again.

Line 43 - 45 doesn’t set the colors? I’m used to Java so I don’t know if object referencing acts the same way.

You are only updating the value of local vars created few lines earlier.
You have to assign those values to the color object.
For example using color.set(r, g, b) or color = new pc.Color(r, g, b)

1 Like