Parenting - Faith in Despair Devlog #13


After Auri had a successful run in Faith in Despair with a deck that was the size of 40+ cards, I noticed a performance hit when shuffling the deck.

I investigated it with the profiler, and the first thing I noticed were some unnecessary FindObjectOfType calls. These are lazy calls that I added and I always pay for them later on. :D I fixed that by caching the objects that I always needed.

The next issue was calling transform.SetParent a few dozen times. In Faith in Despair, I enjoyed setting parents of cards where they would be physically. For example, cards in the deck are parented to the Deck gameObject. Cards in graveyard are parented to Graveyard, discarded cards in DiscardPile, and so on.

Turns out that setting a parent is expensive, because it goes through all children and does some adjusting and redrawing and recalculating and recaching and what not.

So, I got rid of all parenting. Thankfully, I saved all cards in a List anyway, so it wasn't that hard. It did have some weird side effects with menus though, and for some reason they disappeared after being killed.

I'm also sad that it's not correct in the hierarchy anymore, all cards are just hanging around in the same group now.

Was it worth it? Definitely. The performance spikes are gone. And I really don't like seeing performance hits on my PC, because that means it's even worse on older hardware.

End Screen

Another important part of the demo (and the game in general) is the end screen. Whenever your run ends, there will be statistics, and a highlight of the best card. Here's the screen with some missing/incorrect stats and missing card (basically a very early version).

There also needed to be a way to return to the splash screen and start a new run. A lot of that required me to refactor the code a bit, especially the statistics. I now have a RunStatistics class and a GameState class. This will be very helpful later on when I implement the Save & Continue feature, which is going to let you keep playing at a later time.

I am Loading

I added a new loading animation when you press end turn. Which one do you like best?

A (End Turn is grayed out):

B (End Turn is gone and reappears when you can press again):

Let me know in the comments (A or B)!

Backgrounds

I decided that each "act" is now called a chapter, so you go through Chapter I, Chapter II, and Chapter III, and each chapter now has a different background. So, every time you defeat a boss, the background changes.

It's subtle, but it feels like it's getting darker towards the final boss.

Target Preview

A much needed feature is the targetting preview. Now you see which lacrima targets which card. It's especially cool to see when a card targets all enemies/allies.

This should help alleviating confusion for new players.

More Changes

The descriptions for each keyword are in separate boxes now (in the gif you can see it on the right side). I added descriptions for each trigger, so you know exactly when each trigger hits. And I added new shop and money icons, because the last ones were a bit confusing.

I fixed even more bugs and - after another playtest session - I now have 11 more bugs to fix, 24 must-have features, and around 35 nice-to-haves.

The scope keeps changing, but the must-haves are quite important. It also feels like system-driven games can become black holes of coding. You can just add stuff and lose sight of where you're actually going.

Kind of reminds me of the time I worked on Personal Halfquake. But this time, I have an end in mind from the beginning and a roadmap to guide me.

🧙‍♂️ To be continued...