Behind the scenes: Optimizing as it grows (Patreon)
Content
Hey there! Hat Jump here with a little look at the development of Make Your Parents Proud. Nothing sexy to see here folks. Unless code talk is your kink, ha!
Time to clean things up
Working on the 4th episode, I realized the game is getting big enough that I should start optimizing with a bigger game in mind. Let me give you a quick rundown of how Make Your Parents Proud operates so far.
Under the hood
You're probably aware already that I'm using Unity. But what you may not know is that for the writing, I'm using an engine called Ink. I like Ink a lot! It feels like I'm writing a novel, but it's code! The syntax is fairly easy to learn. And it's free!

You can even playtest your story on the right as you write it. Neat!
If you have any interest yourself in interactive fiction, I encourage you to give it a try. Twine is another popular engine for this type of stuff. I haven't used it though so I can't assess which is better. But at least aesthetically, I prefer Ink.
The award winning game, 80 Days, was made using it. I still need to get around to playing that:(
Integration
The tricky part for me then, was integrating Ink with Unity. Fortunately, and this is a big reason why I use Unity, I found a guide from someone who has already done it: Making a visual novel with unity. (The Ink discord community is also extremely helpful)
But...
As useful as that guide was, I believe it was intended for a small project. As I create more and more assets for Make Your Parents Proud, things are starting to become unwieldy.
For example, my Backgrounds gameobject is already becoming cumbersome.

By the time I'm done with the game, there might be hundreds of backgrounds. So I've been restructuring the game, by having individual episodes have their own scenes in Unity, with their own unique Backgrounds gameobject that only has the backgrounds needed for that specific episode.
Sounds pretty simple right? He he...
I mean, it sort of is, but as seems so often to happen in coding adventures, one adjustment has a sort of ripple effect.
You see, to avoid having to save and reload the game every time we load a new scene, I used the DontDestroyOnLoad() function on my InkManager, which holds all our game data. But the InkManager needs to have references to other important gameobjects, like my BackgroundMananger and CharacterManager, and when we load a new scene, those references becoming missing.
No problem, I just need to find the new BackgroundManager and new CharacterManager and link them back to my InkManager again. So why wasn't this working????
My theory is that they weren't fully loaded before the code was trying to link them. Well, coding is all about problem solving, so how do we solve this problem? There's probably many different ways. My solution was to have the parent container of the BackgroundManager and CharacterManager find the InkManager in it's Start() function, and then tell the InkManager to find them. This forces the InkManager code to wait for the necessary gameobjects to load before running. In other words, it gets the greenlight from the required gameobject itself. Voila, it worked!
This is just one of the adjustments being made as I prepare the game for its future. I'm hoping to get a lot of this work done now while it's still smallish. The longer you wait to optimize, the bigger headache it is.
I hope that wasn't too convoluted:/
Until next time!
- Hat Jump