May 5, 2017

Suzy Cube Update: May 5, 2017

#SuzyCube #gamedev #indiedev #madewithunity 
I thought the image up top was appropriate given that, nope... Level 4-4 still hasn't progressed at all...
Ugh, what a week. Sorry for being a Debby Downer, but it just feels like I've been struggling with bugs all week.

Ray of Hope

Ok, maybe I should start with something that actually went well. My Piggy Banks are a little less dumb now. Don't get me wrong, they are still pretty dumb, but they actually make an effort to avoid obstacles and corners now.

Debug view of obstacle avoidance algorithm

I've added some checks which you can see illustrated in the screenshot. The algorithm is, actually, quite simple. As the Piggy runs, it performs a raycast forward (blue). If this raycast hits an obstacle, a reflection vector is calculated and another raycast is performed (white). This continues, shortening the raycast with each reflection, until a raycast returns no obstacle collision, at which point the last raycast direction becomes the Piggy's new desired direction.  In the example above, after bouncing around in the corner a few times, the Piggy's ultimate turning direction will be to its left, thus away from the sign and corner.

The technique is quite simplistic and not really all that smart, but that's ok. Suzy Cube isn't a game about outsmarting brilliant enemies. I just needed chasing Piggy Banks to be more fun and challenging instead of a simple matter of steering them into a corner for an easy reward. 

Rolling up my Sleeves

Now on to the bane of my week! Rolling blocks... A struggle that, actually, started last week.

First off. One of the uses I had planned for these rolling blocks was to create an enemy of sorts who would chase Suzy and leave a trail of lava pools behind itself. 

Rollin' rollin' rollin'

Not bad, right? Here's a secret. For this little baddy, I simply ended up hand animating the rolling rather than relying on my, still barely functional, rolling block script.

So, what is the state of this rolling block script? Well... not bad... but not great either.

Wanna go for a ride?

After MUCH fiddling and fudging, I ended up with a block that can reliably roll along it's own forward/back axis. This means that, by rotating the block on its vertical axis, I can, essentially, point it in any direction and roll it back and forth. Great, right? Sort of. It seems to work fine for this ridable block up here, however...

Believe me, it's janky...

...When I set out to make this spiked tumbler block, I discovered that the waypoint based movement script I'm using to move and rotate the block doesn't play nice with the rolling behaviour and gives very shaky looking results. The low framerate of the gif hides the motion artifacts, but believe me, the motion on this thing is unacceptably jittery in the game.

I hate to, essentially, duplicate code but I think I'm going to simply integrate the waypoint based movement right into the rolling behaviour script. The issue seems to be that as both scripts attempt to move the cube, there's a conflict occurring. Perhaps I'll even use a completely different approach to handle the movement. We shall see. All I know is that I can't leave it as is.

Dang! I was really hoping for a nice, up beat, update full of progress and sunshine. Alas, another whiny cry-fest. No one ever said game development was easy! On that depressing note. I shall bid you farewell. I need to get back to banging away at this rolling block problem! Until next week.

No comments:

Post a Comment