Skill Tree Activated

The quest to become an indie game developer

#100DaysOfCode#100DaysOfGameDevC#CodingIllogical BaconScript-writingUnity

Rogue Code Found!

Day 093 #100DaysOfCode
Day 057 #100DaysOfGameDev

For days I had struggled with the code for getting the change in animation states to work correctly when collecting a Power-up. The Power-ups could be collected, and they would cause FP’s animation state to change to the new Power-up Idle state, but the effect would only last for a second or two and then it would revert back to the standard Idle animation state. The code looked absolutely right for what I was trying to do and made total sense to me, but just would not work properly. It was maddening to try and figure out why.

I finally had to make the call to abandon all hope of figuring it out, accept that it was doing what it was doing, and set myself to the new task of building a workaround to the way the code was functioning. This didn’t take me too long and before I knew it I had a patch in place that was giving me the results I desired, however clumsily-implemented it was. I had my working animation state.

Proud of what I had finally accomplished, I wanted to clean up my scripts after making a mess of them over the last couple of days and started deleting notes I had made and just generally tightening things up. When I finished working on my FlappyPig script, which is where all this work had been done, I decided to take a quick look at the other scripts I currently had open to make sure they were tight as well. That’s when I found it: Rogue Code!

the Rogue Code (nullified before being deleted)

This one little snippet I had placed in my GameControl script was the root of all that had ailed me for the past few days. This one little stupid piece of code, which I had apparently placed there thinking I was going to take another route with my implementation, was the sole reason my key boolean variable kept resetting itself to False when I needed it to stay True. This one little bastard block was the cause of infinite levels of madness and despair. And of course I would find it now that I had carefully constructed a full workaround and completely circumvented the ill effects of this unwanted mongrel. *Sigh*

workaround removed

Anyway, I was glad to have found it. It made me feel better to know that I wasn’t going crazy and that my originally planned code actually did work the way I intended once I removed my workaround. This one gets chalked up to lessons in being thorough and hopefully I won’t get snagged up on a similar situation in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *