Remake Roller Splat with Unity 3D and Playmaker - Changing background color and animating floats
In this Unity and Playmaker tutorial series I'll recreate Roller Splat. PART 8 - I'll be adding colors to an array and changing the color of the background on each level complete and animating that color using a Float variable. Absolutely NOCODE. Also check out How to Make a Bounce Game Series http
Changing the background color on every level adds variety and energy to a Roller Splat clone. This part stores a palette of colors in an array, reads the camera's current background, picks the next color from the array, and smoothly animates between them by easing a color (and, underneath, a float) over one second.
Build a color palette array
After the level is created, you'll change the background color. Create a new variable as an array and choose Color as its type, naming it Background Color Palette. Set the array size to 7 (you can adjust later). Fill the slots by clicking each color and moving around the color wheel, keeping the saturation and value range consistent and on the lighter side so the backgrounds don't compete with the level itself.
Get the current background color
Add a Finished transition to a new state called Get Current Color. The background color lives on the main camera's environment settings, so lock the level manager FSM, drag the camera into the state, and use a Get Property action. Choose the Background Color property and store it in a new variable called Current Background Color.
Pick the next color from the array
Add a Finished transition to a new state called Get New Color. Use an Array Get Next action (Array Get Random is an alternative) on the Background Color Palette array so it steps through the colors one at a time. Store the result in a new variable called Chosen Color.
Animate between the two colors
Add a Finished transition to a state called Animate Background Color. Use an Ease Color action to animate from Current Background Color to Chosen Color, unchecking Use Variable where needed to feed the chosen color in. Set the duration to one second and store the animating result back into Chosen Color so it updates each step of the ease.
Update the camera every frame
Ease Color only animates the value; the camera still needs updating. With the FSM locked, drag the camera in and add a Camera Set Property action, choose the Background Color property, uncheck the variable so you can supply Chosen Color, and set it to run Every Frame so the camera's background continuously matches the animating color. Now each new level eases the background from the current color to the next color in the array over one second.





