I looking for the programming logic behind the following scenario: I’m trying to change the color of sprites from Blue → Red as they are get more and more far away from a particular point on space.
So, as the sprite as at a further distance from a particular point in screen, the color of their SpriteRenderer should change accordingly.
This is what I’ve done right now:
if (distanceBetweemCenterAndSprites > 10.0F)
{
sprites[pos].GetComponentInChildren<SpriteRenderer>().color = new Color(1.0F, 0.0F, 0.0F);
}
The code simply calculates the distance between the centre (the point) and the sprites. If Distance > 10.0F, the color of all the sprites become red. What I want is a progressive change in color (from Blue → Red) but I can’t seem to find a logic to do so. Any help is appreciated, thanks.