top of page
Search
  • 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!


Overview


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.



Feedback


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:


PlayerMovement.cs


<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;

    }
}

MouseLook.cs

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);

    }
}

FMODCntrl.cs


<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);
        Event.start();
        Event.release();
    }

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

Get a download key for the itch.io demo:


https://denizen-interactive.itch.io/defend-the-nhs/download/SribvhPiWwb5bHzyHZBu88Dfa-iJqBGQXX1tXxHvcRfaYHFoJREWJs

https://denizen-interactive.itch.io/defend-the-nhs/download/hwEw7zUovkGLh2BF4ZBu88Dfa-hsVYJuVBsxkJ7yRh3sz6LLm4PTZ

https://denizen-interactive.itch.io/defend-the-nhs/download/gJe5rvpkLMxAWi4eTZBu88Dfa-zZ4jJaQAC9qcGtwCK8GCU64mYSDs

https://denizen-interactive.itch.io/defend-the-nhs/download/JTsHZqigkAdZy327YZBu88Dfa-TCCsshz6sBGnY5A1T8GF8rMzWzk

https://denizen-interactive.itch.io/defend-the-nhs/download/vbSqamgdwYKBSRmJdZBu88Dfa-F5rt8KmqywT72e9ASXBig1Cqjcgs

https://denizen-interactive.itch.io/defend-the-nhs/download/YkqPegW223rot6x35ZBu88Dfa-MgZLUQLEGcErdecN61CrgUUqGuy

https://denizen-interactive.itch.io/defend-the-nhs/download/wuNxBcLXz5gQMz9y8ZBu88Dfa-D8yYfuixcJNmcGfyUXYBxhsRpkGh

https://denizen-interactive.itch.io/defend-the-nhs/download/8seWjXw7QK4pFGMo1ZBu88Dfa-TmN4VD2Q8kKHHbwSKfbyxB5pWUZ

https://denizen-interactive.itch.io/defend-the-nhs/download/QUsnHTzQFuseGZYdxZBu88Dfa-oyqxNBwcK2rbMyWDNkeeMqVorRP

https://denizen-interactive.itch.io/defend-the-nhs/download/wKEQtgQLNacaXcGsJYbKbfTTYP-JkpHq7mAZYSbm55wF3J61kY8fnRp

https://denizen-interactive.itch.io/defend-the-nhs/download/8TexRcNHegH5ytT14YbKbfTTYP-Jdt2Sr9BW74fL4Vvk9z9KarQknf

https://denizen-interactive.itch.io/defend-the-nhs/download/QcsXyXhNhHyKSBC6TYbKbfTTYP-pVyBXchNLpRqMGLszRTWNd5kyfgp

https://denizen-interactive.itch.io/defend-the-nhs/download/pmSnXTtw71eAtTiXYYbKbfTTYP-a5BZRoBY3cGouNadv3tDCGLyLGp

https://denizen-interactive.itch.io/defend-the-nhs/download/euqdhP5ftTLZMks4dYbKbfTTYP-A1qubxRN8gwHfjpsJ98PQKpiPJd

https://denizen-interactive.itch.io/defend-the-nhs/download/GhEUcJYhJhpBFpEU5YbKbfTTYP-i6FyjZoGCuZWofTbjBqXP3Q8X5Zs

https://denizen-interactive.itch.io/defend-the-nhs/download/tUek9N4r5e68GKSpoYbKbfTTYP-XEP1N84eZ6x1higydQQmt9kf5zD

https://denizen-interactive.itch.io/defend-the-nhs/download/WMsK69UxfEPQjbdi1YbKbfTTYP-hGV12eCaWQdWbK6LbbCAADAzygqs

https://denizen-interactive.itch.io/defend-the-nhs/download/3WS1NnpuXqhpUtFgxYbKbfTTYP-ZaNLitxAqhzfvK3Zn7B2rQUJCktp

https://denizen-interactive.itch.io/defend-the-nhs/download/keqR8zqqARkdewpXsZbKbfTTYP-BcMYnHgyMC4XZx6Z8bqzg96A4HTh

https://denizen-interactive.itch.io/defend-the-nhs/download/h4RQBpAKvyMbzEnmcubKbfTTYP-a7EEzyjpk6RkrScp47kDJtPtMzvs

https://denizen-interactive.itch.io/defend-the-nhs/download/gWFx5AkGL2sDTYGb6ubKbfTTYP-tvVdt6ZQvjthwGvjU4XMXLaJF7us

https://denizen-interactive.itch.io/defend-the-nhs/download/JCDXG12DkwjFuFTR8ubKbfTTYP-S1npLHrYZGrnrgv7uisFgeLWHRL

https://denizen-interactive.itch.io/defend-the-nhs/download/vocnF8QwwmQS4fCE1ubKbfTTYP-cpGw88iWw26gzXAmJ7eTvmCd8vP

https://denizen-interactive.itch.io/defend-the-nhs/download/YxreM5Nf2MahqPinxubKbfTTYP-V7Mh7R8cu2U5CEE94Kw65fChfhg

https://denizen-interactive.itch.io/defend-the-nhs/download/wfRUudhhzAmCHgsvpvbKbfTTYP-HB99UB8tXiLvHGumXz84YvCCff4s

https://denizen-interactive.itch.io/defend-the-nhs/download/8EFkSZtzPYTHkxNkfvbKbfTTYP-w1PGj5XkskCK5CCFi7cCTQEvtyXp

https://denizen-interactive.itch.io/defend-the-nhs/download/QQDKz75Ao39uUES2UvbKbfTTYP-YGoUvRt3MaMNsaSWHcNrbZzmf9Bh

https://denizen-interactive.itch.io/defend-the-nhs/download/pZc1XQYtDjFWCXdQHvbKbfTTYP-cVeLNrxWFvMHrqjNM21QoQ7hyKVp

https://denizen-interactive.itch.io/defend-the-nhs/download/e6rSnL4qdKW33FFN4vbKbfTTYP-rubed6bCTj3LjTHeCGNhMnyrURFp

https://denizen-interactive.itch.io/defend-the-nhs/download/xQbQ7MTKc1fa7u17AGcKbfTTYP-Si3kmhXtoJf69TnxEYu94vfDM8xs

https://denizen-interactive.itch.io/defend-the-nhs/download/2ZzxrHHGp7o6vBnKpHcKbfTTYP-reGa1axv1iaRHBkkVr7DLhnj3NWs

https://denizen-interactive.itch.io/defend-the-nhs/download/U5PXZUfDShVKP7G9fHcKbfTTYP-MDGVSoEyaZnKW1AvH2NDPn63H1Ep

https://denizen-interactive.itch.io/defend-the-nhs/download/Fi8nf3A9iewAqkTyBHcKbfTTYP-QMicfGkang5x5mavdmQekD89DQGp

https://denizen-interactive.itch.io/defend-the-nhs/download/SrUeesmaGEiYJsCoGHcKbfTTYP-Ujs7x3BgeRcyxsw6megPH2jxRA1p

https://denizen-interactive.itch.io/defend-the-nhs/download/hwbUUy2sgqXwmKidMHcKbfTTYP-ttosKWm1DSXUyKZW1nPzESn45Efp

51 views0 comments
bottom of page