Aug 5, 2016

Suzy Cube Update: Friday August 5, 2016

#suzycube #indiedev #gamedev #madewithunity 

No more distractions for a while! I've finished the work I was doing for the Embassy and can now fully commit to Suzy again. Finishing said work, though, means this is going to be a slim update.



After upgrading to Unity 5.4 last Friday, I found myself obsessively going back to my project all weekend, probably because I knew I would have to set it aside for most of this week. At first, I just wanted to finish fixing the stuff that got busted by the upgrade, like the lightmapping and filing bugs with Unity for the stuff I couldn't fix myself, but I found myself in a sort of dev groove and flipped open the laptop several times to tinker with things and fix bugs even though my wife and I already had a pretty packed weekend.

Early gif of the double jump in action

So, after last Friday's update, I continued work on Level 4-B. Not done yet, unfortunately, but I fixed up some stuff with the boss fight and improved the layout of the level as well. Over the weekend, I also addressed a longstanding bug with the Double Jump power-up which made it a bit unreliable. Basically, I resorted to the double jump script doing its own check for whether Suzy is on the ground or not rather than polling the Character Motor script for the info, which was proving unreliable in some edge cases. It now works like a charm.

We had some folks over for board games on Saturday and one of the guys has been asking about trying Suzy for months. Well, he finally got his chance and I think he was pleasantly surprised! As always, getting to watch someone play and ask them what was going through their mind at the time yielded valuable fodder for my to-do list.

Will you stop following me!?

I was able to squeeze some time in on Monday (which was a holiday) while my wife was out to lunch. I fixed a bug with the Mummy Skull enemies which was causing them to revive regardless of how they were killed. Certain things, like fireballs and explosions, are meant to kill them permanently. Fixing the bug also involved improving the basic enemy script, so good work all around.

From Tuesday to Thursday, it was all outside work, though I did bring a notepad with me so I could brainstorm ideas for upcoming levels and take note of ideas for some bug fixes I had been contemplating.

On Thursday afternoon, I mostly took it easy, but I did squeeze in a couple of fixes based on observing my friend playing on Saturday. One such change was kinda funny. I had recently sped up my coin rotators (rings of coins which rotate around a center) in order to make them less annoying for folks who just want to stand there and let the coins run into them, but apparently, I may have sped them up too much. The guy who played on Saturday actually started up Level 1-1 and said, "Oh, I guess those hurt me, right?" referring to the four rotating coins which greet Suzy upon spawning. This had never come up before the speed change so I figured the fast rotation made the coins look too aggressive. There is nothing like tester feedback!

And that, finally bring us to today. I decided to knock a couple longstanding annoyances of my list. One was purely aesthetic and the other was a bug that's been around forever!

I reworked the jump through platforms a bit to make them both look and animate better but also in such a way as to have them better transmit the fact that you can stand on top of them but pass right through the bottom.

Kinda ghostly lookin'

The old design used to look more like an outline of the platform, so I changed up the texturing to something more like an umbrella so it fades off toward the bottom. Hopefully this better conveys their use. This new setup also lead me to writing another handy script allowing triggerable scale changes to objects. That's what I'm using to "pop" the platform back into existence.

The bug I fixed today has to do with what I call "step rotate platforms". These are platforms set to rotate a certain amount, then wait, then continue rotating, etc.

Around and around...
These have been in and working for over a year. I wrote the script back when Suzy Cube was just me fooling around with Unity on weekends. Over the months and months, though, I've had to tinker with the script as it's always been error prone. Initially there were synchronization issues. These were caused by the fact I was incrementing the platform's angle at every frame rather than making the platform's angle a function of the current time. In fixing the sync issues, I introduced a new bug, a rare hitch that would happen every once in a while. This hitch was very jarring as the platform would pop to the wrong angle for a frame causing the camera to jossle trying to keep Suzy in frame. I made a few attempts at fix this hitch, but could only ever diminish its occurrence, never getting rid of it completely. Well, I think I've done it, through another change in my approach. 

The hitch was caused by the fact that I was having the platform rotate by a defined number of degrees, then stop, and so forth based on the current game timer. The issue would happen every once in awhile because, there was a value I had to essentially loop at every revolution and because of floating point imprecision it would sometimes pop to the wrong value for one frame before continuing as intended. This bug was hard to reproduce and depended on how long a level had been running as well as the framerate. I knew I needed a better approach and I had one in mind.

I make liberal use of an object type in Unity known as an Animation Curve. If declared as a public variable, this will expose an editable curve in the editor which is super for controlling any sort of transition or object motion. There's a really handy function for evaluating values along the curve, so it's really easy to use too. What I did to fix my problem was to switch to entering a number of turns per full revolution rather than entering a number of degrees by which to rotate at each turn and to use that along with the other editable variables such as rotation time and wait time to programmatically build an animation curve representing not a single rotation but an entire revolution. Here's what the curve looks like for the rotator seen above:

One step at a time

The bottom of the graph represents a rotation of zero degrees and the top is three-sixty degrees. As you can see, even the stops between rotations are accounted for in the animation curve as the plateaus which are visible between the slopes. All I really need to do is evaluate the value at the current time to get the platform's current angle and since the curve is set to loop, I don't even need to keep track of revolutions or anything. I was even able to quickly set up both clockwise and counterclockwise movement by simply multiplying the current time value by -1 to have the curve run in reverse. Animation Curves are really handy!

Wow.. Kind of a long update considering I "didn't work on Suzy" this week! That's what happens when I concentrate on low hanging fruit, I guess! I've got a, mostly, full week of Suzy coming up and I plan to concentrate on finishing up that World 4 boss level! See you all next week!





No comments:

Post a Comment