Another Day, Another Update: Dynamic Stage Textures
Two updates in two days, hopefully i can keep this momentum going! Adding dynamic stage textures was probably the most difficult update i’ve had to do in TRASHTASTIC for some time now. But i’m going to keep this very short, like i originally promised.
I already had my ground texture made up from weeks ago when i first started creating assets. To get the desired effect i was after i used the hue and saturation settings on my texture. I saved a different setting for each point in the dynamic texture cycle, for a total of 40 new textures. I loaded them up into unity and began scripting a new array to hold all of the textures.
Writing the script was new to me because i hadn’t worked with arrays before this point. It was rather complicated at first but once i understood how it worked everything came together quickly. First i set up a variable (ecoScore) to be used as the index for the new array, ecoScore is just a combination of my good and bad points to create a total score. It’s the same method used to calculate the players high score at the end of each stage with a slight difference. Because my score system can drop into negative numbers and arrays start from zero and only increase in value i had to include a base integer of 20 (20 being half the total of textures in the array) this way my array can decrease in value with my ecoScore without breaking anything in the script. I used a dynamic variable instead of a static number so that i wouldn’t have to write 80 different statements in the script, this way the renderer uses the index to pick a texture and the index number is set to my variable which is constantly changing relative the players action. This whole function is called once a frame.
After that i added a couple of if statements to make sure that if the player continued to score/lose points after the highest or lowest value texture had been assigned, that the game wouldn’t break. This just tells the game that no matter what, index 40 and 0 are the arrays limits.
I still plan to add other goodies if the player continues to score past the array limits but they won’t have any affect on ground textures. That’s all there is to it. Hopefully this new update was short enough, i could have kept writing about it for some time, but all you really need to see the is script in action.