top of page
  • Writer's picture1/4" Jack Of All Trades

Computational Environments 2: Defend the NHS

Updated: Feb 4, 2021

"Boris Johnson and the Conservatives have done nothing to protect the NHS, now it is up to you!

If you even touch a mutation and you will get infected. Let too many mutations attack the NHS, it will be overwhelmed.

The green mutations go straight for the NHS and the red ones are after you.

Pickup powerups to help you and the NHS survive for as long as you can!"

W,A,S,D to move and left click to shoot!

The different viral mutations

Download keys at bottom of the post!

My highscore is 508!


This week we were asked to make a prototype game, so I made a survival first person shooter/base defence game using Unity and the audio middleware FMOD. The objective is simple: defend the NHS and yourself from viral mutations as long as you can. The green mutations will head straight for the NHS and chip away at its health, whilst the red ones will go directly for the player and try to infect them. The green ones will also infect the player if they get in their way. The enemies arrive in waves, each one bigger than the last, with faster enemies spawning at shorter and short intervals. I wanted the game to feel frantic so I made the enemies kill in one hit to increase the perceived urgency.

Design Thought Processes and Philosophies

I intended this project as an exercise in coding best practice (both in terms of efficiency and ethics). As such I also wanted to test the implementation of some design patterns that I had been investigating, and move away from my usual programming approach of a messy web of singletons; in particular I tried to focus on the ideas of the Object Factory and State Machine. The process was a valuable learning experience that tested and honed my coding ability, but one that also left me with reasonably well abstracted code that can be used again in future projects.

I also tried to avoid controversial language in my code, making references to scripts as 'main' and 'aux' rather than 'master' and 'slave'. Unfortunately this is language that is still in use in the audio industry and in the audio middleware FMOD used for this project (which must have a bank labelled 'master' to actually operate). I also had further thoughts on the topic of language with regards to the use of the words 'kill' and 'die', opting instead to use 'infect' or 'overwhelm'. My thoughts on the matter stem from the idea that COVID-19 is a globally shared human experience and as such I would want it to be as accessible and relatable to as many as possible. In an updated version of this game I would also opt for a syringe (or other appropriate medical equipment) over the use of a gun to fight off the mutations, weary of the potential messages attached. However, for the purposes of a first testing I do not believe this issue to be too severe.


After extensive playtesting by myself and housemates, I noticed that a lack of auditory feedback was detrimental to the player "immersion", in an experience that otherwise seemed to be largely enjoyable if a bit stressful for some. Wanting to prototype the whole experience more realistically I added the audio middleware FMOD to the project, preferring its usability over the built in Unity audio capabilities, and quickly cobbled together some audio events using the contents of my sound library.

Here are some notable game events that I felt NEEDED audio even at the prototype stage:

- shooting + hitting an enemy

- the NHS getting hit

- a warning ambient sound for the mutations (thinking along the lines of a creeper in Minecraft), especially given the high risk they carry.

- acquiring a pickup

FMOD settings and a politically charged Easter egg

Additional Features That Could Be Implemented:

- Add a start screen (maybe add difficulty settings)

- More enemy types

- More powerups

- More interesting/varied environments

- Particle/visual effects

- Create bespoke SFX

- More complex audio integration (including footstep system)

- Dynamic music that changes every X waves and reacts to NHS health (not just placeholder music)

Also, inspired by some of the Future Learn assignments I began considering what changes I could make the the games rules and how they might affect game play. Two that I have come up with are:

1. Making the red mutations invincible, except if the player has the extra shots power up - the only way to get rid of them otherwise is to get them to collide with one another. This could add an interesting dimension whereby you have to balance the remaining green mutations to ensure that you will be able to get rid of any red ones. However, could create game states that are unwinnable and this might prove to be 'unfun'. Still might be worth testing though.

2. Make the enemies spawn smaller and smaller - could increase the frantic feeling of the game and increase the difficulty level.

Code Snippets

Thought I would include the two code snippets that make up my first person character controller and the start of my FMOD event factory:


<Not added jumping yet but that's what the isGrounded boolean is for, got distracted by tweaking spawning mechanics and progressive enemy behaviour>

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
    [Header("Player Settings")]
    public float speed = 12f;
    public bool speedyPickup;
    public bool extraBulletPickup;
    //public float health = 10;

    CharacterController player;
    Vector3 velcocity;
    float gravity = -9.18f;

    void Awake()
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<CharacterController>();

    void Update()
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");
        if (speedyPickup == true)
            speed += 0.05f;

        if (GameManager.main.isRunning == true)
            Vector3 move = transform.right * x + transform.forward * z;

            player.Move(move * speed * Time.deltaTime);

            velcocity.y += gravity * Time.deltaTime;

            player.Move(velcocity * Time.deltaTime);

        else return;



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseLook : MonoBehaviour

    public float mouseSensistivity = 80f;
    GameObject player;

    float xRotation = 0f;

    void Awake()
        player = GameObject.FindGameObjectWithTag("Player");
        Cursor.lockState = CursorLockMode.Locked;

    void Update()
        float mouseX = Input.GetAxis("MouseX") * mouseSensistivity * Time.deltaTime;
        float mouseY = Input.GetAxis("MouseY") * mouseSensistivity * Time.deltaTime;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        player.transform.Rotate(Vector3.up * mouseX);



<FMOD Factory: still in a basic state, needs FMOD parameter options for added complexity, but allows for 2D or 3D sound sources to be created on the fly by calling FMODCntrl.main>

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FMODCntrl : MonoBehaviour
    public static FMODCntrl main;

    void Start()
        main = this;

    public void CreateFMODInstance2D(string EventName)
        FMOD.Studio.EventInstance Event;
        Event = FMODUnity.RuntimeManager.CreateInstance(EventName);

    public void CreateFMODInstance3D(string EventName, Transform target)
        FMODUnity.RuntimeManager.PlayOneShot(EventName, target.position);

Get a download key for the demo:

52 views0 comments


bottom of page