The joys of collision detection

So as you can see from our previous post, the platforming elements of the game seem to be fairly well in place.  You might even say they’re 90% there.  Ah, but that last 10%, that’s where all the hard bugs are!  So in reality it’s more like you’re 50% done and you just didn’t know it yet.  An example of this came up in the past day or so when I noticed a hard to reproduce bug having to do with landing on the edge of a platform at just the right angle.  If done right, the character gets stuck in the “jumping” state and never transitions to “landing”.  That is until they begin to fall at the far end.

Best I can tell it seems the CharacterController is reporting flags as “None” and thus I don’t switch to landing until I get the correct flags when the character begins to fall again at the far end of the platform.  Strange.

Even if this wasn’t an obnoxious bug to hunt down (and the problem still might just be with my own code!) there’s another issue with the capsule shape that the CharacterCollider uses.  Since the capsule is rounded at the bottom, the character appears to sink into the platform as you get near.

Finally, even if all those issues were solved there’s one more.  When you move the character horizontally at the edge, sometimes gravity doesn’t pull the character down far enough to contact the platform again.  For a single frame you’re floating and that causes my game to show the falling animation.  The following frame you’re back to touching so you revert to the idle animation.  This flips back and forth very rapidly and causes a very jarring jitter just as the character is stepping off the edge (but only when moving relatively slowly).  The effect is much more pronounced walking down an incline of some sort as this video shows.

So, in the next few days I’m going to see about implementing my own version of a CharacterController type script, but using a box so we can get nice crisp falling off platform edges.  The downward slope is still a problem and will have to be handled differently but at least the first two problems *should* be resolved.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s