Post news RSS Counter Sniper: Scripting the Billboards

How I created the dynamic billboards in Counter Sniper with Unity Visual Script.

Posted by on

Art12 Nameplate

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.

SC Billboard3

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.

Art12 Pic1

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.

Art12 Pic2

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.

Art12 Pic3

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.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.