Time For Bed Dev. Log (Version 4)

Time For Bed was made in 48 hours by 6 people during Global Game Jam 2019 - Pittsburgh. There, it took home the award for Jammer’s Choice. a few months later, Swapnil Mengade, lead programmer of the project, submitted the game to the TOKYO SANDBOX game show, where it got selected for showing. COVID postponed the show, but we have since decided to port and optimize the 2-day game jam game into a more full-fledged release for both PC and mobile devices, prioritizing mobile devices. The game’s systems all work as a playable prototype, but we plan to build more levels and game types into the final release, so a fresh project was the logical next step. We chose Unity 2020 and a target audience: Mobile.

Player Controllers

Understandably, the game jam version of Time For Bed was made very quickly with little time for discussion of future work on the project. As a result, this version of the game uses a monolithic Player Controller script. To the left, you can see a small snippet of the original PlayerController script.

Immediately, I realized that this PlayerController script actually controlled two types of players with a simple public bool check: isParent (seen here on line 21 and checked for on lines 52 and 56). If checked true in the Unity editor, the player GameObject is a Parent, and if unchecked, the player is a Kid.

Instead of one monolithic script, I decided to use this important bool check to separate this PlayerController into two separate ones: a ParentController script and a KidController script (see below).

In creating the two new Controllers, I also wanted to remove the input checks from Update that you can see on lines 50 and 51. Using Unity 2020’s new Input System, the ParentController and KidController will wait for the player to use a stick or push a button before pinging the rest of the script, rather than checking every frame for inputs from the player.

Player statistics like movement speed, parent’s grab range, kid’s jump velocity, and parent’s throw velocity (lines 16, 24, 31, and 39 respectively) were all great details we were able to implement as soon as we did during the game jam. Without the amount of testing we were able to get done for the game, these mechanics would not have felt as great as they did at the end of the game jam. In early discussions for the mobile port, however, Swapnil and I knew we wanted to have different types of Parents and Kids with unique move speeds, jump velocities, or grabbing/freeing ranges. For this challenge, I decided to use Scriptable Objects for all of the player statistics.

Parent can take in scriptable object variables, walk, climb stairs, detect when kid is nearby, grab kid, put down kid in bedroom.

For Kids, these stats are things like jump velocity and move speed. Kid can take in scriptable object variables, walk, climb stairs, jump, and wake up other kids.





Input System:
Unity’s new Input System is great and allows way more flexibility through Actions rather than waiting for a KeyCode press during every frame in Update. Instead, the new Input System allows you to dedicate all kinds of inputs from different devices like mouse/keyboard, controllers, and mobile devices into one single action you check for in your scripts. I’ve come to the realization that it allows for much faster growth of a project in case buttons need to be moved around, but the action will still stay the same in your code. I also decided to prototype a select screen because I couldn’t playtest both a parent and kid. I used a PS4 controller and mouse and keyboard for players one and two, respectively.

Main Menu

Note+Aug+27%2C+2020+9_52_33+PM.jpg

Cinemachine follow cams.

up/down functionality

This script takes one UI Canvas array and one Cinemachine Virtual Camera array. On player input, it cycles up or down through the arrays. Since they must always cycle together, a single integer (currentCanvasAndVCam) is used for both arrays. EDIT: After learning a bit more about the UI functions in the Unity editor alone, I decided to incorporate more editor functions to enable and disable different game objects within the editor. I use these in conjunction with the private int in the StartMenu script (now called currentMenuAndVCam)

Blend between cameras on player input (move action and back to the bottom floor when going from settings to play). Ask Swap Why I get errors and how to cycle between a list. Simple. Check for it.

For simplicity’s sake, Swapnil also recommended I convert both currentVCam and currentCanvas into one single integer. This new one is called _currentCanvasAndVCam.

For left and right functionality, I used Unity’s Navigation UI feature, explicitly telling each button where to go.

The Local/Online button toggles the Play button’s features. If Local is set, then the play button will take the player to the local multiplayer screen (Name, Host game, Available games nearby, or back to main menu). If online is set, then the play button will take the player to the online multiplayer screen (Name, Host [Create game], Public [find game], private game [enter code], or back to main menu).

Simple AI with state pattern (this pattern is used in computer programming to encapsulate varying behavior for the same object based on its internal state) (a little too advanced for me… Instead, I just used a simple animation of them walking back and forth until Swap gets AI up and running)

For the Settings menu, I wanted an audio mixer to control the volume settings. But it wasn’t actually working so I found this YouTube video which did the trick: https://www.youtube.com/watch?v=xNHSGMKtlv4

Set minimum value of sliders from 0 to 0.001. Added Mathf.Log10 because mixers are set to decibels.

Mobile Devices

Game Controller

The simplicity of the game made porting this one pretty simple. The only trouble I had was in Swapnil’s original implementation of AllCHildren Asleep. His read as backwards to me, but after asking him why he implemented that way, here is his explanation:

Loading Screen

Created an enum script for more user-friendly build index management.