I’m trying to change my camera bg color from light blue to black.
I’ve had a few tries and it doesnt seem to work for some reason.
the part where “as time goes by do X” works great i added logs to see its working, but the actual changing of the color isnt working.
i’ve tried using HSV, i dont know what i need to do exactly to take it down slowly (i want it to be gradually turning into full black, not all at once), since i’m not changing between two numbers completely, i just need to take it down with a small amount each time, and its more than 1 color, its not only blue or green, its both.
Yes exactly, in a script over time.
a little background - i’m creating a basic jetpack game and i want the background to become more and more dark until it gets to full black (like u’re in space).
so i’m starting with that blue-ish color, and i want to make my way down.
tried something out and it works, but although i’m using Lerp its still not smoothing out the way i want it to, it seems very clear that its changing , not really gradually.
thinking about making it “change every x seconds” maybe that will smooth things up?
i just want it to smoothly turn into black given a certain amount of time.
The first two parameters to Lerp are the “start” and “end” value, not the “current” and “target” value. You’re probably thinking more along the lines of MoveTowards, but Lerp doesn’t operate the same way.
If you want to make the background color get darker depending on your height, you could do something along the lines of this:
var t = Mathf.InverseLerp( startingHeight, endingHeight, currentHeight );
Camera.main.backgroundColor = Color.Lerp(startColor, endColor, t );
Where startColor is your blue, endColor is your black, startingHeight is the height at which you want to start fading to your endColor, endingHeight is the height at which you want to finish fading to your endColor, and currentHeight is the current player height.