PPP Week 6

Overview

This week was truthfully not very productive for me, but I did create a system to allow workers to gather resources, which can be commanded both with eye tracking and voice recognition, fixed a bug in the speech recognizer, and started to work on combat. Aside from that, I fixed various bugs here and there, and I added a debug tool to print out the contents of the speech recognizer to the screen.

Gathering

A while ago, I was reading about some of the development process of my favorite game series, The Sims. In the article, Will Wright mentioned that Sims are inherently dumb. They do not know to go to the fridge if they are hungry, or to the bathroom if their bladder is full. Instead, objects in The Sims are smart. They call out to Sims, and Sims go to the ones that fit them best.

I used this idea in designing my gathering system. My units are stupid. They don’t know where anything is. All they know is that they must gather a certain material, and their inventory is empty. So, when the player commands units to gather, hex tiles call out to the worker and beckon them forward. The worker then decides between all of these tiles which one fits their needs best and is closest.

I was amazed to find that this system worked on virtually the first try.

Workers gathering stones

Obviously there’s a lot of work to do on the movement and animations to really polish this system. But as it stands, workers can gather resources, and when they deliver the resources, the player gains them. This allows for a fuller game loop where the player can now create buildings, create units, gather, and create more.

Gathering with both voice and eyes was incredibly easy to hook up. With voice, I either tell all of my workers to gather a resource, and they’ll flock to the nearest one. Alternatively, I can select units and make only them gather resources. With eyes, again, I either select my units and then select a resource tile to have them gather, or I select a resource tile and all workers gather from it. Interestingly, with this system of tiles calling out and workers choosing them based on personal circumstances, if I select a resource tile across the map, the workers will still gather from the nearest resource of that type. This is a conscious decision, but as the game becomes more fleshed out, I might want to change that.

Speech Recognizer Bug

Much like when a stray hair moves suddenly in your peripheral vision, and you swear that it was a spider, this particular bug turned out not to be a bug at all.

Occasionally, but without any particular pattern, my speech recognizer would cease to function. My patchy duct tape solution to this was to find when my speech recognizer had an error and turned itself off, and to turn it back on. This didn’t work. I also had a manual key, ‘R’ for “Restart,” to reboot the speech recognizer. That also didn’t work.

It took me way longer than it should have to realize that when I was rebooting my new speech recognizer, I wasn’t creating a new script without deleting my previous one. That caused my game to have major lag spikes whenever it “restarted.” After I fixed that issue, I realized the restart wasn’t actually necessary at all.

My speech recognizer wasn’t just throwing an error and crashing. It was running for too long without input, so it shut off.

So, to resolve that issue (which should have been solved by setting a longer timeout period, though it wasn’t), I simply restarted event itself whenever it shut off. I’m glad I developed a debug tool that showed my speech recognizer’s status and output to the screen, or else I might not have caught this quite frustrating bug.

One thought on “PPP Week 6

Leave a comment