APRIL 22 → APRIL 25 – 2024

Tasks

Technical Developments

  • Transitioning forest from dead to alive
    • As the player collects all trash, the forest should react accordingly. For this I added a new script that is used on every tree, this script holds a reference to the dead- and alive tree. Then, when called from the GameSceneData script, the tree will transition within a set time. (see code & gif below)
  • Major issues with referencing prefabs
    • During the week I encountered some issues where objects would not be active even when they clearly were. After hours of debugging I found that I had set up my GameManager all wrong and had been using references to the prefab of the environment instead of the instantiated version at runtime. This led to major issues where I was unable to call any methods and do anything else that had to be done so I had to rewrite a part of the original script but the logic was still solid. (see code below)
  • Added lerping between grass textures
    • After consulting Alejandra we decided on a method to lerp between grass textures when the player has collected all trash. She made the shader and I got to implement it in code.
      (see gif below)
  • Added new interaction to pick a flower seed
    • As our client had previously mentioned that he would like small interactions all over the place, I came up with an idea. As we were using a generic seed for the flower spawning and spawned the same flower every time, I thought it could be cool to have a choice. So I implemented the flowers that Alejandra made and added flower packs from which the player could choose.
      (see gif below)

Miscellaneous

  • Mid term presentation
    • Presented our current progress to our assessing teachers and our client. They provided us with a good amount of feedback which was then applied and processed accordingly.

Double Diamond

This week was an accumulation of small improvements that brought a major improvement to the scene. The goal was to implement several visual improvements and fixes like removing the fire, transitioning the trees and lerping the grass.

Discover

My research this week was not through online sources but instead through consultation with my team members. Moreover, I mainly discussed with Alejandra how to approach certain parts like lerping the grass, but also how to transition the trees and make it look good.

Define

We decided on a simple grass lerp in a shader that Alejandra would make, after which I would implement it in script. Next to that, we decided that simply scaling down one tree and scaling up another would be more than fine.

Develop

I took these definitions to Unity and implemented them as proposed. I also created a separate editor script so it would be easy for Alejandra to implement new trees and toggle between the dead/alive ones. Next to that I implemented the grass lerping by adding a boolean that waited for the trash to be collected.

Deliver

These developments resulted in a few videos that were sent to the client as well as in our teams discord to receive feedback.

Plan

Next week I plan to get started on the next scene and it’s interactions. These include picking up paper, but more importantly I aim to figure out the paper physics during the week as I want to create a semi-realistic behaviour.


Research

As mentioned the research this week was mainly from discussing with Alejandra and learning more from her about shaders in Unity as well as trying my hand at editor scripting again.


Reflection

Another solid week in my opinion. I got quite a number of things done and brough major improvements to our current scene, as well as finalising some parts that had been backlogged for a while.

The collaboration between the artists and myself went really well too and I feel like we are on the same wavelength in terms of communication and expectations.

Media & code

Transition between dead and alive trees.
Flower choice through coloured ‘packs’ and corresponding flower spawns.
The grass lerp in action through the editor.
Playthrough with characters and localized pop ups.
private void HandleTrashCollection()
    {
        int index = (int)Mathf.Floor(trashProgressScript.ReturnCurrentScore() / actionPoint);

        if(index <= particleSystemsBase.Count - 1)
        {
            particleSystemsBase[index].GetComponent<ParticleSystem>().Stop();
        }

        if (index <= particleSystemsExtra.Count - 1)
        {
            particleSystemsExtra[index].GetComponent<ParticleSystem>().Stop();
        }

        if(index <= treeSwitcher.Count - 1)
        {
            treeSwitcher[index].ActivateTransition();
        }
    }1private void HandleTrashCollection()
    {
        int index = (int)Mathf.Floor(trashProgressScript.ReturnCurrentScore() / actionPoint);

        if(index <= particleSystemsBase.Count - 1)
        {
            particleSystemsBase[index].GetComponent<ParticleSystem>().Stop();
        }

        if (index <= particleSystemsExtra.Count - 1)
        {
            particleSystemsExtra[index].GetComponent<ParticleSystem>().Stop();
        }

        if(index <= treeSwitcher.Count - 1)
        {
            treeSwitcher[index].ActivateTransition();
        }
    }
    [SerializeField] private GameObject deadTree;
    [SerializeField] private GameObject liveTree;

    [SerializeField] private float speed = 1.0f;
    [SerializeField] private AnimationCurve blendCurve;

    private Vector3 initialScale;
    public bool transitionActivated = false;
    private float blend = 0;

    protected void Start()
    {
        initialScale = transform.GetChild(0).transform.localScale;
    }

    private void Update()
    {
        if (transitionActivated)
        {
            blend = Mathf.Clamp01(blend + Time.deltaTime * speed);

            float modifiedBlend = blendCurve.Evaluate(blend);

            deadTree.transform.localScale = initialScale * (1 - modifiedBlend);

            liveTree.transform.localScale = initialScale * modifiedBlend;

            if (blend >= 1)
            {
                transitionActivated = false;
            }
        }
    }

    public void ActivateTransition()2
    {
        if (transitionActivated)
        {
            transitionActivated = false;
        }
        else
        {
            transitionActivated = true;
        }
    }
  1. Method to handle the trash collection, turn off the fire and toggle the trees to transition. ↩︎
  2. By calling this method, the blending will start and end when it reaches the full value. ↩︎