Changing Level Color

levelColor

I made the level change color after a certain distance this is controlled by the PaletteController, it takes in preset colors in the inspector.

the code for switching between them after a certain distance is below, the background object is what changes the color. Here it gets a reference to the SpriteRenderer for all sections of the level and then in the update method loops through all the background renderer to change the color after a certain distance. the color of spike hazards wall attachments will also need to have its color changed. here I have hard coded the distance numbers these could be moved into variables for better readability and management same with the color selection.

Leave a comment