Final Changes & Bug Fixes

Throughout this week I’ve been changing some minor things which I decided to put all in one post.

I worked on the lighting for a long time, it’s at a point where I’m happy with it but I would like it to be a lot better.

I spent a while on the post-processing testing different settings such as bloom but in the end all I edited was the chromatic aberration which I have on now to give it more of a sci-fi look.

I created a new beacon model as before it was just a cylinder. It has two parts, the inner part and the glass shell.

In the 2nd Puzzle, I’ve added in new lights as before they didn’t look very good so now it at least looks like the light is coming from something.


Start of Time Attack Segment

I reconfigured the entire time attack mode with the help of Brandon Nyman as he helped me do it. Originally I had teleported the player into multiple scenes which while it worked, was not good for editing so we managed to make it work all in just the main scene.

Because of how I have set it up, I had to make a new instance game object rather than just using the GameManager. So this instance has a gameMode integer which tells the main menu script what it is loading in. So a value of 0 = the main game, 1 is time attack area 1 and so on.

So this is the script which does all of the timings and loading the correct time attack. So there are a 5 spawnpoints in my main scene which at the start of the game, when we load in, a switch statement determines what number the gameMode is depending on what button in the main menu we press. So for Case 1, it is moving the player’s position to the 1st area spawn point and is turning all of the objects and timers that need to be turned on for that specific time attack. Once again, I would like to thank Brandon Nyman for helping me with this as he taught me a lot about this.

public GameObject[] areaSpawnpoints;
public GameObject player;
public float timer;
public float bestTime, newBestTime;
private bool timerOn;

public TMP_Text timerText, bestTimeText, endText;

public GameObject timeAttackCanvas;
public GameObject[] endFlagCanvas;

public PlayerElectricity playerElectricity;
public Jetpack jetPack;
public DoubleElectricity doubleElectricity;
public MagnetPower magnetPower;

void Start()
{
    timeAttackCanvas.SetActive(false);
    timerOn = false;
    for (int i = 0; i < endFlagCanvas.Length; i++)
    {
        endFlagCanvas[i].SetActive(false);
    }

    playerElectricity.enabled = false;
    jetPack.enabled = false;
    doubleElectricity.enabled = false;
    magnetPower.enabled = false;

    //This is for the time attack mode where if its a value greater than 0 it will load the corrosponding time attack scene.
    switch (Instance_Script.instance.gameMode)
    {
        case 1:
            player.transform.position = areaSpawnpoints[0].transform.position;
            timeAttackCanvas.SetActive(true);
            endFlagCanvas[0].SetActive(true);
            bestTime = PlayerPrefs.GetFloat("Area 1 Best Time", 999);
            timerOn = true;
            UpdateText();
            break;
        case 2:
            player.transform.position = areaSpawnpoints[1].transform.position;
            timeAttackCanvas.SetActive(true);
            endFlagCanvas[1].SetActive(true);
            bestTime = PlayerPrefs.GetFloat("Area 2 Best Time", 999);
            timerOn = true;
            playerElectricity.enabled = true;
            UpdateText();
            break;
        case 3:
            player.transform.position = areaSpawnpoints[2].transform.position;
            timeAttackCanvas.SetActive(true);
            endFlagCanvas[2].SetActive(true);
            bestTime = PlayerPrefs.GetFloat("Area 3 Best Time", 999);
            timerOn = true;
            playerElectricity.enabled = true;
            jetPack.enabled = true;
            UpdateText();
            break;
        case 4:
            player.transform.position = areaSpawnpoints[3].transform.position;
            timeAttackCanvas.SetActive(true);
            endFlagCanvas[3].SetActive(true);
            bestTime = PlayerPrefs.GetFloat("Area 4 Best Time", 999);
            timerOn = true;
            playerElectricity.enabled = true;
            jetPack.enabled = true;
            doubleElectricity.enabled = true;
            UpdateText();
            break;
        case 5:
            player.transform.position = areaSpawnpoints[4].transform.position;
            timeAttackCanvas.SetActive(true);
            endFlagCanvas[4].SetActive(true);
            bestTime = PlayerPrefs.GetFloat("Area 5 Best Time", 999);
            timerOn = true;
            playerElectricity.enabled = true;
            jetPack.enabled = true;
            doubleElectricity.enabled = true;
            magnetPower.enabled = true;
            UpdateText();
            break;
        default:
            print("Default");
            break;
    }
}

void Update()
{
    if (timerOn)
    {
        timer += Time.deltaTime;
    }

    if (timer > bestTime)
    {
        newBestTime = timer;
        bestTimeText.text = newBestTime.ToString();
    }
    else
    {
        bestTimeText.text = bestTime.ToString();
    }

    timerText.text = timer.ToString();   
}

private void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        StartCoroutine(WaitLoad());
    }
}

public IEnumerator WaitLoad()
{
    if (timer < bestTime)
    {
        switch (Instance_Script.instance.gameMode)
        {
            case 1:
                PlayerPrefs.SetFloat("Area 1 Best Time", timer);
                UpdateText();
                break;
            case 2:
                PlayerPrefs.SetFloat("Area 2 Best Time", timer);
                UpdateText();
                break;
            case 3:
                PlayerPrefs.SetFloat("Area 3 Best Time", timer);
                UpdateText();
                break;
            case 4:
                PlayerPrefs.SetFloat("Area 4 Best Time", timer);
                UpdateText();
                break;
            case 5:
                PlayerPrefs.SetFloat("Area 5 Best Time", timer);
                UpdateText();
                break;
        }
    }

    if(newBestTime < bestTime)
    {
        bestTime = newBestTime;
    }

    timerOn = false;
    endText.enabled = true;
    //charController.enabled = false;
    yield return new WaitForSeconds(5f);
    Cursor.lockState = CursorLockMode.None;
    Instance_Script.instance.gameMode = 0;
    SceneManager.LoadScene("MainMenu");
}

private void UpdateText()
{
    //bestTimeText.text = "Best Time: " + bestTime.ToString();
    bestTimeText.text = bestTime.ToString();
}

End of Time Attack Segment


I tried for many hours trying to get the canvas to change between keyboard and controller however in the end I thought this would be better and easier to do.

I’ve now animated the beacon so it spins and I also gave it a spotlight like a real beacon so now it feels more alive.

I’ve now added in a rumble sound effect by the beacon so it isn’t just silent.

In the Mirror rooms in Area 2, I’ve added sound effects to them all as before they for some reason didn’t have the sounds. I should have made it a prefab when I was making this puzzle months ago but I didn’t for some reason so I had to do it the long way.

Here is a video commentary of my game that goes into more detail about all the mechanics.

search previous next tag category expand menu location phone mail time cart zoom edit close