This is not an article about billboarding sprites and I realize that the name is probably confusing. It’s more about how to use lists and random integers with [Unity’s Visual Script](visual script link), or actually that’s all that is. So, let's get on with it.
The billboard is a relatively simple prop in Counter Sniper, but this week it’s my favorite because it allows me to shoehorn non-sequiturs and bad t-shirt ideas into my game without adding any dialogue or context. So, let’s quickly go over how it’s scripted.
The billboards have a script machine attached to each canvas that is triggered at the start of each round. The script runs a randomizer between 0 and 5 and decides which material to show based on the RNG.
All those random numbers correspond to a list as seen above. The randomizer decides which slot is called. Each slot is a different material that gets layered onto the billboard. The script is attached directly to the canvas, so the object that gets its material reset doesn't have to be specified through a variable. Just the “This” tag.
And that’s it. Fairly simple, but when I was trying to make this I couldn’t find any good tutorials for how to use lists or randomize variables or split a flow multiple ways. So, that’s it. Do with it what you will.
If you want to see more lower-level scripting tutorials, follow me on IndieDB. If you want to berate me for being so vague in the tutorial, you can join the Discord. And if you want a choppy and inconsistent stream of all the content I’m creating, check out my Twitter.