01 / Devlog, August 15 '21: bug fixes


GitHub: https://github.com/nebulousmango/The-Body-Metallic

Document references:

  • Game design doc: link

Patch notes:

  • Changed OnCollisionEnter to OnCollisionStay in the Jump region of the PlayerController script: fixes a jump bug in which the b_TouchingFloor bool changes to false if the player comes in contact with two Floor layer objects. This was an unfixed bug that the March 2021 project had too.
  • Added "Time.timeScale = 1;" to any function which restarts or loads a scene: fixes a load scene bug in which I had to open and close the pause menu after loading a scene to be able to do anything. This was because I had a "Time.timeScale = 0;" in my pause menu's script. If I clicked any of the buttons in the pause menu, it would load the new scene with the time scale still set to 0, and I'd have to open and close the pause menu again to get it back to 1. I added a line setting the scale to 1 in the ButtonManager script's functions.
  • Added an additional IF condition to the Fail script's OnTriggerEnter function: stops the player being susceptible to death even if they've already died. In the case of a moving fail state object like the pendulum, the player would get hit over and over even after they'd fallen to the ground during their death animation. Each hit counted as a new death, and the death animation and coroutine would run again. This stopped happening after I changed the Fail script so that it only ran the player's Die function if the player was alive (which is checked by the b_alive bool).
  • Added an additional IF condition to the switch pressing function: fixes bug that lets the player open a door over and over. Initially, the interact overlay (which is a UI prompt for the player to press E while in the switch's proximity) would turn off after the E key was pressed once, but the player could press E again and keep running the Open Door function on the same door more than once. Like with the repeated player death bug, I added the DoorOpened bool to the IF condition in the Switch's Update function.
  • Disabled switch trigger's box collider after the player opens its corresponding door: turns off interact overlay after switch has been pressed once. If the player pressed a switch and stood in place, the prompt would still stay on screen because the SwitchTriggerEntered bool only changes when the player exits the collider. This is a little unintuitive, so I added "GetComponent<BoxCollider>().enabled = false;" to the Switch's Update function. The player automatically "exits" the collider if it's turned off.
  • Added a bool check to the IF function in the Podium script: fixes problems with receiving input from GetKeyDown within an OnTriggerStay function. This was a bug that I had in the Dec 2020 project too: pressing the spacebar wouldn't reliably work in triggering the Win script. Instead of running the GetKeyDown condition within the OnTriggerStay and Exit functions, I added the WinTriggerEntered bool instead. Keyboard input is checked in the Podium's Update function instead, with the additional condition that WinTriggerEntered is true (so if the player is within the Win Trigger's collider and presses E, a new scene's loaded).
  • Made objects that play an animation clip the child of the parent object that holds the script that triggers the animation: fixes an inaccurate animation problem. In this case, both the switch and door objects use an animation clip I made in Unity by recording a change in the object's position. The clip doesn't work properly when the script and animator components are in the same object though: if I made a second door, it would teleport to where the animation was recorded when its own OpenDoor animation was triggered. The animation's only work like they're supposed to if you make an empty game object and put your script in it, and then make your object with the animator component its child.
  • Added object with box collider as camera's parent: fixes camera clipping through meshes, like the camera being able to go through walls. Reducing the Clipping Planes' Near value didn't help with this because the camera could still sit inside a mesh, and that would make the entire object invisible.
    • This has still got a problem with restricting the player's movement though. The camera and player object have some distance between each other, so a collider on the camera would mean the player can't move backwards as much as intended.
    • Another camera problem: because of the way the camera and player object are attached to each other, the player moves around in a circle when looking around instead of just turning around in the same spot. So looking around inadvertently moves the player's position.

Get The Body Metallic