Basic C# Scripting

I have started to learn C# Scripting and its implications for audio are staggering! I know, I should have learnt the basics a long time ago, but its sort of like expecting every programmer to learn a minor pentatonic arpeggio. The point I’m making is that scripting, like music is just another language and although it seems daunting and confusing in the beginning, becomes rewarding and enjoyable with practice and study.

Another audio student at SAE-QANTM has shown me a link to Brackeys, an awesome website with seemingly endless tutorials on all types of programming with something for everyone, from novices (like me) to full-on programming gods!

Switch Statements

The tutorial that inspired this blog is about using switch statements and how to use them in the context of a text-based math quiz. First, we built a random number generator so the quiz doesn’t get boring and then used different replies for right and wrong answers, switching between three different wrong answers to make it less repetitive.

C# Script in MonoDevelop
C# Script in MonoDevelop-Unity

What this script gives you is a basic page with text that asks you a math problem, you then type your answer and if it’s correct, the statement “Well Done” appears, if your wrong then it hurls abuse so fast you have to duck!

4 x 8 = 100 !#@$
4 x 8 = 100 !#@$

If we compare the photo above and below, then we see that case 2 – “you’re not even trying” was selected at random.

Family Friendly Version!
Family Friendly Version!

For this blog I have kept the Response-Index family friendly, but it is funny to type rude answers in the responses, which makes the process a form of comedy, and the more enjoyment you can have, the more you can learn.

If we bring this concept of having a Response-Index into the games audio realm, then imagine using the same principle to get different vocal reactions from your team members or enemies. If you were to record a multitude of different responses from the characters you interact with, then randomized the responses so they don’t become annoying and repetitive, then that is one step closer to immersion and we have done our job, all thanks to basic C#.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s