Mar 16, 2018

Suzy Cube Update: March 16, 2018

#SuzyCube #gamedev #indiedev #madewithunity @NoodlecakeGames 
Unfortunately, I've been sick this week. That means a short update for a couple of reasons: 1. I spent a lot of time resting and 2. I want to get this over with so I can go back to resting. So, on that positive note, let's get it on!


Exterminator

Through I didn't get much done this week, what I did get done was pretty darn important. I fixed two big, hard-to-reproduce, bugs. One was, potentially, progression blocking and the other, well, you'll see.

Down you go

So, our first bug involves the Skull Bullies. These enemies can not be defeated simply by bopping them on the head and must, instead be knocked off their platform. Once in a blue moon, however, they would get caught on the edge of the platform in their falling animation and not actually fall. This was especially problematic in those instances where defeating them opened the path ahead! In these cases if this bug reared its ugly head, progress would be blocked! Well, no more! The solution was so simple, I can't believe it didn't occur to me sooner!

Most enemies in the game, make use of what Unity calls Root Motion to get around, meaning that most of their movement about the playfield is actually driven by their animation. So how did I fix the issue? Simple, in the animation which precedes the falling loop, I added some backward motion to the character, so when Suzy pushes a Skull Bully to the edge of a platform now, the falling animation itself ensures it won't get caught on the edge! Yay!

The next bug was a bit more involved. It was another hard-to-repro issue with catastrophic results. I'm talking, lose-track-of-the-player-character-break-level-culling-potentially-skip-most-of-the-level-get-out-of-bounds results!

The bug happened if Suzy ever found herself inside another collider for a frame. The physics system would pop her out, but then the Character Motor script, which controls her movements, would interpret the move as a sudden jump in velocity, resulting in...

Blast off!

Here, I've simulated the conditions by suddenly enabling a platform halfway inside Suzy's collider. In gameplay, this would manifest most often when jumping on rotating platforms. Like I mentioned, it was pretty rare, but with some practice, I was able to make it happen pretty consistently. So, I knew how to reproduce the bug, I knew what was causing it, so now it was time to fix it.

My first go at it was a simple naive approach. I created a new maxYVelocity variable and experimented with using it a couple different ways. I tried capping Suzy's upward velocity to maxYVelocity, ensuring she could never fly up too fast. This kind of worked. I also tried, setting maxYVelocity quite high and zeroing out Suzy's Y velocity if it ever exceeded it. This, also, kind of worked. The whole approach broke down, however, as soon as jump pads got involved. Some of the game's jump pads can shoot Suzy up pretty darn fast, fast enough that I had to set maxYVelocity so high to accommodate, that it hardly helped with the blast-off bug at all. I needed a smarter solution.

What I realised is that all instances of Suzy willingly blasting off at high speeds always come from external stimuli like jump pads and that these impart this velocity via a single function in the Character Motor script: SetVelocity(). So, what I did was to, essentially, allow these external stimuli to set their own, temporary maxYVelocity from within this function. If no call to SetVelocity() is made, then a default maxYVelocity is used instead (about the same as a normal jump). Since the bug resulted from a sudden jump in velocity, but without an external source then the effect is now capped to the default maximum.

Boing!

So, yes, physics object interpenetration can still happen, there's little I can do about that. But, with this fix in place, if it does happen, the result is an inoffensive hop and not Suzy rocketing off to the moon!

This bug had been an illusive thorn in my side since the very start of the project! I'm so glad to have finally come up with a satisfactory fix!

Off to GDC

I was really hoping to give you all a sneak peek at our new trailer ahead of GDC, but I asked for a couple of last minute changes last night when I saw the latest cut. It's looking good, though! We will be showing it off during the conference, of course!

After some time-zone confusion, I finally had my call with Noodlecake on Wednesday. We've mostly got things all set for GDC, we know what we'll be announcing and showing off and now, if we can just fix this crash bug that showed up out of nowhere... GOD DAMNIT WHY CAN'T THINGS JUST WORK!!!!!????

... I mean, if we can just fix this one itsy bitsy new bug, we'll be golden...

Given that I'll be at GDC next week, my update schedule will, undoubtedly, be affected. I may or may not post little updates throughout the week, but I'll definitely aim for a roundup on Friday or Saturday. See you all then!

P.S. If you are planning to attend GDC, hit me up on Twitter (@LouardOnGames) so we can high five in person!



No comments:

Post a Comment