Category Archives: C#

Transmutation: Camera Effects

Unity has some image effect standard assets that allow some pretty cool things to be able to happen to the camera.

Image Effects

Importing Image Effects

I started to fiddle with and check out all of the image effects on the camera, what they did, and which ones I thought would be appropriate to use.

I had Noise Grain: But chose not to continue trying to make it work.

Noise Grain.JPG

It didn’t add anything to the game play or make it feel more interesting. It was cool but didn’t change the atmosphere or experience that I was going for. Noise Grain is out.

I came across motion blur. It felt like if a person was to get radiation this is probably what they’re going to see.


0.92 Motion Blur.gif

Maximum Motion Blur

This was great, but I’d have to find a way to make sure that the player’s current radiation level on each character was affecting the amount of motion blur that the camera put out.

Motion Blur Script.JPG

Access the Proper Motion Blur Script

Because of the camera switching players and there only being 1 camera, it was easy to find the parent object constantly and get that parent object (player)’s radiation level. Then make the motion blur amount to 100th of the radiation level. Because the radiation level goes from a scale to 0-100, and the motion blur from 0-0.92. The divide amount is a set variable so there’s no magic numbers. But the / halfDivideAmount – I’ll get to that in a bit.

So the motion blur would increase with the players radiation and become more intense with the more radiation the current player had. Until it reached its maximum of 0.92. It looked pretty crazy but I knew I wasn’t going to leave it at that.

Next was bloom (makes colours brighter and more vibrant). Transmutation relies on the emphasis of lighting. Bloom just makes it more beautiful.

This slideshow requires JavaScript.

I fiddled with the Bloom Intensity for a while to try and find the right value. Bloom 3 was a really nice amount. 15 Was really cool, but obviously too much. So I decided to roll with three and give it a proper play test.

This slideshow requires JavaScript.

If a few mutants or radioactive goop puddles ended up close enough to each other it proved to still be a bit too ridiculous. I’d also recently discovered ToneMapping. This is a hard one to explain. “Monitors (along with others) all have a limited dynamic range (LDR) that is inadequate to reproduce the full range of light intensities present in natural scenes. Tone mapping addresses the problem of strong contrast reduction from the scene radiance to the displayable range while preserving the image details and color appearance important to appreciate the original scene content.” (WikiPedia). It evens out the amount of colour per pixel that’s close enough to each other to fit withing a 255 RGB (W & B) range? Or something? Anywho, It works!

This slideshow requires JavaScript.

I was still able to have the 3 intensity of Bloom and have the ToneMapping work its magic to make sure radioactive goop puddles didn’t become a pile of suns.

I thought about making the bloom scale with the players radiation level much like the motion blur. But after play testing with the tonemapping activated and the bloom set at 3, I was content. Although at the start while the level is much more empty and less bloomy, letting the game take it’s course and spawn mutants and radioactive goop puddles never became overwhelming but only more beautiful as time went on.

It came to a point where I found more image effects that seemed like they would be applicable if someone was suffering from radiation. Vortex!


Vortex allowed me to make vortex in the middle of the screen. I thought that along with the player getting motion blurring with radiation, why not have the vortex change between two values to give the effect of wobbling. I started with an angle of 25 to -25 (A range of 50).

This slideshow requires JavaScript.

Then I had to design the system to make it change between these two values. I wanted the angle to have a maximum and minimum value but change how fast it wobbles between the two based on the players current radiation level.

Vortex Script.JPG


Much like the motion blur, I needed to make the script I’m making access the ImageEffects.Vortex to get the angle of the vortex.

  • Start the current vortex angle on 0.01f (It’s not noticeable).
  • Have a countingUp bool = true (To make sure the vortex starts adding).
  • Make the camera get the parent player (because this changes)
  • Determine how fast the angle is going to change based on the current players radiation level.
  • Start the angle changing. If the current vortex angle is not maximum – Start making it ++ towards the maximum value by deltatime * vortexRate.
  • If the angle is at the desired maximum, start making it — down towards the negative value.
  • Set the vortex angle to the currentVortex.

When this came into play along with Bloom and Motion Blur – having maximum angles of 25 and -25 was a bit too much. It was completely mind boggling, It was really hard to comprehend what was happening and what you were supposed to be looking at or doing.

I changed the maximum and minimum values to be 10 and -10 (range of 20). The range of 20 made it still easily recognizable to understand whats going on and what you’re actually doing. Changing between the max and minimum at a rate of (makeFloat 5) was an ideal speed.
For Example: If the current player’s radiation was 50.
The vortex rate would be: (50 / 5) = 10.
Then the angle is changing by + or – by (Time.deltaTime (which is anywhere between 0.03 to 0.075 on my computer) * 10) which is anywhere from 0.3 or 0.75 per frame.
In a span of 5 frames at a rate of 0.75 the angle would change 3.75. And if there is a range of 20 it would be changing from max to min in 5.333(more) seconds.
At 90 radiation: The vortex rate would be 90 / 5 =18.
0.075 * 18. In 5 frames it would change 6.75. It would change from max to min range in 2.96296(more). That amount doesn’t make ME sick. And I hope it doesn’t make others sick. So as the radiation increases so does the speed of rate the angle of the vortex. If the rate needs to be smaller or higher all I have to do is adjust the makeFloat value.

At this point I also changed the maximum amount of motion blur. And as I mentioned earlier. The HalfDivideAmount. Read the big block of Green text.

Motion Blur Script

50% of motion blur at almost maximum radiation along with Bloom and Vortex was the perfect amount.

The one last image effect that I thought would add to the radiation would be something that resembles the player blacking out. Like A Vignette?


There was also an image effect for that too. And much like the motion blur.

Vignette Script.JPG

I’d need to access the Vignette script directly and apply the exact same principles. Because the vignette intensity goes from 0-1 (then anything over 1 makes the game white) and 1 intensity would make the entire screen black – the player wouldn’t be able to see what they’re doing from about 80 radiation and on wards. So 50% (0.5) intensity on TOP of all the other image effects would be more than enough to represent the player blacking out / dying.

Vignette Game.JPG

Are you ready? READY FOR THE MAGIC?

Until next time –



Leave a comment

Posted by on August 25, 2016 in C#, Game Dev, Post FX


Tags: , , , , ,

Transmutation: Audio

For Transmutation – I recorded some audio for certain things. Some ow sounds for mutants and players, an elevator will arrive sound/s, some menu bips when selecting or changing buttons and sourced an elevator ding sound.

To get the Audio for the menu bips to play. Inside the method code that runs when the button is pressed – it plays a random bip sound.


Source PlayRandomBip

But I also wanted a way to play a random bip sound when changing between buttons. After some research I found out that buttons have an event trigger – on Select, and on Deselect are the ones I wanted. When the event system knows that this is the selected object. It will run the events that I parse into it. In this case, on Select is – Activate a highlight behind the button and PlayRandomBipSound(). On Deselect is to just deactivate the highlight behind and not to play another bip sound. Because changing from one button to another is always going to require one Deselect and one Select event call. If both Select and Deselect had PlayRandomBipSound() it would play two sounds every time a change of button occurs.

For a small fraction of time I used one of my previous tracks that I made as a placeholder Main Menu track, and the main Game scene had my placeholder background track for quite a while. I used the audio source Play On Awake and Loop for the background music.

Main Menu BGM

All of these were only placeholder until the audio students sounds were complete. Or at a stage for us to implement. Although there was a short list of audio in our asset list to give them examples of the sounds we were looking for, Ash Ball and Chris Ware went above and beyond.


The Background music that we ended up using for the Main Menu – Game Scene – Game Over scene was this track: The intensity of the music changes over time, and we can set the intensity within our game itself so the background music will loop on the appropriate intensity. The intensity of the game increases with each playable characters radiation becoming greater and greater.

There is a unity attachment called FMOD that allowed us to connect to the background music and change the intensity. I’m not familiar with FMOD at all currently, one of the programmers Pritish on my team set it up and implemented the sounds through it. Theres still a few more sounds to implement but we have a good portion of them there. I’m sure this won’t be a one-off for FMOD and I’ll come to learn how to use it. Pritish was the initial contact point for the audio students and set out their work for them and what we wanted. One of the weeks that we were catching up with the Ash and Chris, Pritish was away and I was going to oversee their progress and where to go from here. In the short 15 minute conversation that we had from the initial contact I got the feeling that these two really knew what they were doing, what we wanted and how to get where we all needed to be. They needed very little direction, no motivation and only a small amount of clarity. They always put their sounds in the google drive folder that we had set up for the team that everyone had access to. They delivered on time and are genuinely great blokes to work with. 100% I hope this isn’t the last time I see either of these two.

Until next time –



Leave a comment

Posted by on August 17, 2016 in Audio, C#, Game Dev


Tags: , , , ,

Scripting Time! Transmutation: Menus

Transmutation Main Menu.JPG

I’m no stranger when it comes to making menus. In my ‘Ball Ball Post Mortem‘ I noted that I made a huge mistake of constructing the game in the free aspect mode. I wasn’t going to let this cause me havoc again. So before I started creating any form of UI, I set the aspect mode to 16:9 and made sure that the UI Canvas scaler was set to scale with screen size.

Transmutation Main Menu Red.png

For the simple main menu of Transmutation all that we needed was a play button, instructions button, quit button and an exit instructions button and the code that would make the buttons do what they are supposed to do. The only difference with Transmutation and other menus that I’m used to creating is that Transmutation is going to be solely operated by a controller, not mouse and keyboard. One of the programmer’s had already set up the controller and mapped the inputs for using the left joystick.

Something new that I had to learn was how to get the buttons to be selected with the controller input. I’ve noticed that when I create a UI canvas, an EventSystem always gets created as well. I did some research and watched tutorials on how to make menus work with controllers and it turns out all I had to do (because the left joystick was already set up) was make the FirstSelected object in the EventSystem what I wanted. And I wanted the first selected button to be the Play Button.

First Selected.JPG

I hit the play button and waited for the magic to happen. But no magic was happening. I wondered why and fiddled with some of the buttons settings. Eventually I made the buttons highlight colour when they were selected a bright yellow.

Transmutaiton Yellow Highlight

Because the buttons navigation was set to automatic – they detect where they can go from their position – and the buttons were always directly above or beneath each other they could only ever navigate vertically. Which was the desired effect anyway.

Button Visualize.JPG

The Yellow Arrows Show Where They Can Navigate To

The instructions button brings up a separate panel for the controller. And now that writing that makes me realize shouldn’t the instructions be called Controls? Yes. ANYWHO.

Instructions Panel.JPG

Controller Input

It brings up this panel with a button that allows the player to close this panel and return to the main menu. But when this panel is activated the back button isn’t selected because the games already been started and the FirstSelected doesn’t apply. So there has to be a way to know what the event system is looking at right? There is. It’s called currentSelectedGameObject. So when pressing the instructions button we should make the panel activate and set the current selected to the back button?

Instructions Panel with back.JPG

Selected Back Button

But even within this menu, I could still use the controller to change the selected button to the other existing buttons in the main menu and play the game or quit even while this panel was activated. Like I mentioned before, if we select Visualize on the button it shows where they can navigate to.

Instructions Navigate.JPG

Back Navigation

The back button could still navigate to the other activated buttons. To fix it, I figured if they weren’t activated they couldn’t be navigated to. Turns out, I was right.

Transmutation Main Menu UIController.JPG

The only other thing that was different and new was using a newer version of Unity where Application.LoadLevel(value or string) had been made obsolete. It still works, but in the next version of unity (from my understanding) it won’t. So why not get into the habit of using the new version now. The new way requires the script to have access to using.UnityEngine.SceneManagement. Then instead use SceneManager.LoadScene(Value or String).

The exact same process was used when I was creating the game over menu that get’s activated by the elevator. Except if they win, it shows a happy face – If every player doesn’t survive, it shows an unhappy face.

Until next time –



Leave a comment

Posted by on August 3, 2016 in C#, Game Dev, Games


Tags: , , , , ,

Scripting Time! Transmutation: Lighting

The game is set inside of a nuclear power plant, and nuclear power plants need siren lights in case of emergency right?

Siren Light.jpg

Like This One

My goal was to create something functionally identical to one of these siren lights. Surprisingly it was extremely easy. It took two lines of code.

Siren Light Code.JPG

Set a rotational speed, and make it rotate in the direction by (time x speed).

Light Gif.gif

Fiddling with such a simple light had my lighting senses tingling. I though what else needs some lighting? The elevator perhaps?


Inspiration piece. Yes I took a photo of an elevator.

Elevator Lights.JPG

Excellent! But perhaps they would be better off only activating when the elevator arrives? The elevator would need to know to activate it’s lights when it arrives. Because the elevator is already counting to when it arrives I could simply insert another method that would activate the lights.

Elevator Inside Lights.JPG

Elevator Lights Gif.gif

I felt like the elevator could be improved on just a little bit more. If the game is supposed to be 4 minutes long and the goal of the game is to escape via the elevator, there should be an indication of how close the elevator is to the 5th underground floor.

6 lights. From left to right (-5, -4, -3, -2, -1, Ground). Next was to change these lights to show the elevator moving.

The elevator would need:

  • An array of all of the lights. = GameObject[] lights;
  • Which is the current light. = int current Light;
  • Which light to change to.
  • The time since the game has started. = float lightTimer =  Time.time (in start).
  • How often the lights should change. = float lightRefreshTimer;

How often the lights should change is determined by the length of the game. If there are six lights, and the game is 4 minutes long, the light should change every lightRefreshTimer amount of seconds.

lightRefreshTimer = (elevatorTime / (amount of lights in the lights array – 1)). Because there are six lights, but the first one is already active, the elevator only has to move down 5 levels, not six.

So if the (Time.time – lightTimer >= lightRefreshTimer)) Change the lights() and refresh the time duration.

This slideshow requires JavaScript.

The SwitchLights() method sets the current light off, Changes the value to the next light, and turns that one on. Each time that method is called it changes the current light to the next one. But what happens if all of the lights have been changed and the timer is still going? I’d need a way for the last light to be the last light. Above the if statement to that checks if the Time.time – lightTimer >= lightRefreshTimer is another if statement. It checks if the current light isn’t greater than or equal to the amount of lights in the light array. If it isn’t it executes the code underneath, otherwise it doesn’t.

Something that tripped me up was not having the levelLights.length – 1.

Index out of array

The currentLight variable starts at 0 and only ever reaches 5. So when it comes around again to the levelLights.length (which is 6) it would try to activate something that wasn’t there. Hence having the -1 to the levelLights.length to make that also = 5.

Elevator Level Lights.gif

Until next time –



Leave a comment

Posted by on July 31, 2016 in C#, Game Dev


Tags: , , ,

Scripting Time! Transmutation: Elevator


Transmutation takes place 5 levels underground in a nuclear plant canteen. Three overnight staff are having their lunch break when something goes wrong. They need to leave the plant and the only way out – is up.

The way to win transmutation is to survive for a total of 4 minutes and enter the elevator to escape. When the game has been running for a 4 minutes the elevator doors will open allowing the remaining playable characters to enter and activate a game over screen.

What the elevator will require:

  • A 4 minute timer.
  • A current timer.
  • A way to tell the doors they can open.
  • A way to trigger the game over screen.

What the elevator doors will require:

  • A way to know they can open.
  • Positions to open to.

The current timer can increase with game time: In Update()   timer += Time.DeltaTime. Then if the timer is greater than the set time for the game duration, tell the doors they can open.

Each of the elevator doors have their own script. The sole purpose of that script is to know when to open, and move itself to the open position. When the elevator has arrived to 5th floor it will change its hasArrived bool to true. Each of the elevator doors are waiting for the elevator to arrive and when it does move to the open position.

Elevator Doors.JPG

Each elevator door has its own openPosition Vector3 variable. They’re in world position co-ordinates because I had great difficulty working with transform.localPosition (as they are a child of the elevator).

Elevator Doors.gif

Now that the elevator doors open it was time for a way to trigger a game over menu. The elevator would need access to the UIController to activate the game over menu and a way to activate the game over menu. For now, a simple OnTriggerEnter with a playable character would suffice.

Until next time –



1 Comment

Posted by on July 31, 2016 in C#, Game Dev


Tags: , , , ,

Scripting Time! Transmutation: Character Switching

Character Switching 0

The latest game prototype ‘Transmutation’ requires the player to be able to control 3 playable characters – but not simultaneously. As it is, the player starts playing the character on the right, we’ll call him Mr. Broom. The other two playable characters Pots and Meat are currently sitting idle. There needs to be a way to switch playable characters – this blog will cover how I made it happen.

An appropriate place to handle the switching would be the GameController. It will end up having multiple scripts, one of which I will set up to only handle the character switching. This script is called ‘CharacterSwitcher’. In order for the character switcher to be able to switch characters it’s going to need to know:

  • What three playable characters we have in the game.
  • What camera or how many camera’s we are using.
  • The position of the camera’s or the positions of where an individual camera will move to.

There are only ever going to be three playable characters, but how many camera’s are we going to use and why? Three cameras and always have them be in the positions they need to be and just activate or deactivate them when needed? Or have a single camera and move it to desired locations?

I chose for the game to only operate on a single camera and move to the position it needs to. Purely because of wanting to always have a consistent view on the game world. Plus it would enable us to do something like an ‘XCOM’ game. Lerp the camera between the player’s its switching between except our camera is a fixed 3rd person perspective from behind the playable character.

So now that I’ve decided on a single camera I’ll set up the CharacterSwitcher script to know what it needs.

This slideshow requires JavaScript.

Character Switcher Camera Spots.JPG

The camera spots are empty game objects that are a child of each of the playable characters. They each have the exact same local position behind each character. Now that the GameController know’s what it needs and has them – I need to devise a way to switch between them. Speaking of switching, why not use a switch statement? The GameController will need to know which character is currently selected and which one it needs to go to.

This slideshow requires JavaScript.

In Start(), tell the GameController we are controlling character one. Everything is set up, now it just needs a way to actually switch. I made switching right E and switching left Q for the time being until we learn how to set up the game with a controller. I called these methods straight in update even though they didn’t exist. On many occasions I’ve created complex methods that never work because I create the system and never call it. This time though, I’m going to completely avoid that.

Character Switching Update

This slideshow requires JavaScript.

The switch statement checks which character is currently selected – and as of start, it’s playable character #1. When ‘E’ is pressed it switches to playable character #2. The <CharacterController> script is the script attached to the playable character that allows the player to control it (if the name wasn’t obvious enough). Each time a switch happens, it gets the current playable character – deactivates its control script so it can’t run around, moves the cameras position to the next playable characters camera position and changes the switch statement to the current character.

*video of Switching*

It’s not Lerping as of yet, but that’s a task for another day, it currently serves it’s soul purpose of switching.

Until next time –



Leave a comment

Posted by on July 29, 2016 in C#, Game Dev, Games