APRIL 15 → APRIL 18 – 2024

Tasks

Technical Developments

  • Scene structure
    • Decided on a structure to use for our project, as the project has boundaries in terms of scale (e.g. five scenes) I decided to use a setup where, based on events, the next method gets called through subscription. (see code and explanation below)
  • Full scene playthrough
    • Finalised the structure of a complete scene, completed with interactions, voice overs and environment art. (see video below)
  • Localization support
    • Installed the Unity Localization package to ensure support for (at least) two languages; Dutch and English. Through the use of a string database I was able to easily add dual language support.

Miscellaneous

  • Mid term presentation preparation
    • Started collecting materials to present at the upcoming mid-term presentation.
  • Procedural art redo deadline
    • Delivered my procedural art project in time.

Double Diamond

Finally a week filled with programming once again, this week revolved around creating a flexible setup for our scenes as well as finishing up a complete playthrough of the third scene. Next to that our client had identified an issue, there was no dual language support yet. So I decided to implement that too.

Discover

My research this time around was based around researching a state-machine. I thought that this would be helpful to control the different scenes and be able to pass on data easily. I also did research into adding multiple language support.

Define

The state-machine was too large for a project like this and so instead I decided to use a subscription system. This would then work through simply subscribing to events and unsubscribing every time. This made the setup easy but possibly more time-costly then using a state-machine. However, having to set up such a machine would be a bigger time sink in total.

Develop

I set up a rigorous approach to the subscription system by using an abstract class that every scene would be based on. Then, the root object would hold this script and also contain the necessary references. After which events for interaction and voice overs were listened to and handled accordingly.
(see code below)

Deliver

These developments resulted in a full playthrough for scene three being available. I sent our client the video below and also created a release on our GitHub.

Plan

My plans for next week include presenting the mid-term presentation, adding a transition from a dead forest to a living one as well as other fixes scene three still needs.


Research

As mentioned the research this week was primarily state-machine based even when I decided against using it in the end. I watched the following videos.
These videos did inspire me to create my own, more specific and smaller setup.

Game Manager – Controlling the flow of your game https://www.youtube.com/watch?v=4I0vonyqMi8&t=497s

How to use Bolt State Machines in Unity https://www.youtube.com/watch?v=SVpkh3kMIcg

Unity 2D Scene Management Tutorial https://www.youtube.com/watch?v=E25JWfeCFPA

Programming a Better State Machine https://www.youtube.com/watch?v=qsIiFsddGV4

Build a better finite state machine in Unity https://www.youtube.com/watch?v=NnH6ZK5jt7o

The State Pattern (C# and Unity) – Finite State Machine https://www.youtube.com/watch?v=nnrOhb5UdRc&t=260s


Reflection

I was really happy with my progress this week as well as finally having a week without major distractions. The code I have written this week was really good and I am sure that it provides a stable foundation for the next scenes.

The part I am most happy with is that I came up with the solution myself, I found that it would be easier to do something small like this even when it takes more time and this also enabled me to really customize it to the experience we want to provide. I had not really used abstract classes before but I saw it in one of the researched tutorials and immediately knew I had to use it.

Media & code

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

public abstract1 class GameSceneData : MonoBehaviour
{
    public abstract void OnSceneEnter();2
    public abstract void OnSceneExit();
}
public class GameSceneAdditionalObject3
{
    public int sceneIndex;
    public int inSceneIndex;
    public GameObject additionalObject;
    public Transform parent;
}
if(scene.sceneEnvironmentPrefab.GetComponent<GameSceneData>() != null)4
                {
                    scene.sceneEnvironmentPrefab.GetComponent<GameSceneData>().OnSceneEnter();
                }
public override void OnSceneEnter()5
    {
        additionalObjects = GameManager.Instance.GetAddditionalObjects();
        audioManager = AudioManager.Instance;

        trashProgress = additionalObjects[0].additionalObject;
        swipeArea = additionalObjects[1].additionalObject;
        seedSpawnpoint = additionalObjects[2].additionalObject;
        popUp = additionalObjects[3].additionalObject;

        audioManager.PlayVoiceOver("ForestScenePart1");
        audioManager.OnVoiceOverFinished += StartTrashPicking;
    }


private void StartTrashPicking()
{
    // First we de-activate the old objects

    // Then we unsubscribe from previous events
    audioManager.OnVoiceOverFinished -= StartTrashPicking;

    // Then we activate new objects and call the needed methods
    trashProgress.SetActive(true);

    // Then we subscribe to new events
    trashProgressScript.OnScoreReached += StartSeedVoiceOver;
}
  1. This class is marked as abstract to be able to override it later for every scene. ↩︎
  2. The class holds two ‘default’ methods. Meaning any script that inherits from this class has to implement those methods. ↩︎
  3. Additionally, this class holds references to objects already in the scene (usually UI). This is done as the instantiated prefab can not otherwise have references to these objects without large costs. ↩︎
  4. This if statement is found in the GameManager script, whenever a new scene is scanned, the script checks to see if it has a script that inherits from GameSceneData (the first script) and if it does it calls the OnSceneEnter method. ↩︎
  5. This is an example of an implemented version of the GameSceneData script, when entering the scene all additional objects are referenced and stored, the first voice over is activated as well as subscribing to an event for when the voice over ends. After it ends, the next method will be called etc. ↩︎
A lite playthrough of our first finished scene.