Friday 8 June 2012

Movement "Helpers"

The topic today is "helpers". I'm not talking about allied NPCs, but about code that helps the player play the game more easily. Auto-aim is at the extreme end of this category, but I generally stick to helpers that improve the player's ease-of-movement.

When you run sideways and there's a person-sized hole in the ground, what should happen? I tend to think that you should run over it. After all, a real human being will not simply drop through a hole just because it happens to be in the way. Then we have to ask, what if the player wants to fall through the hole?




This is where helpers come into play. If the player character is moving, the floor helper detects any small holes and stops the character from falling into them. When the player stops on top of one, the opposite happens. The player character might be nudged a few pixels to make sure they fall through. Unlike an "auto-aim" helper, the player always has almost complete control in this case.

I use helpers for holes in the ground, the ceiling and walls. Ceilings are easy. Jumping causes a slight nudge toward the center of the hole, and the object/entity can pass right through it.

Wall helpers are a slightly different beast. With them, you need to check the character's vertical velocity and make sure that they don't get pushed through the hole while falling at an incredible velocity. That just looks strange. I also tend to only allow wall helpers to act when characters are falling, not when they're moving upward. That way, if the player planned to jump up past a hole in the wall, they can.

There are some important to remember when creating a helper. They're probably pretty obvious, but I'll mention them anyway.

  • You need to detect ground/walls on both sides of the hole, otherwise players will be nudged toward all sorts of empty spaces, when they should really only be nudged into these specific areas
  • Always make sure that the entity/object is trying to move toward the hole, or you'll annoy people by pushing their characters in the wrong direction
Movement helpers work great for grid-based games like the ones I've been posting about, but they work for any sort of 2D game. They aren't usually as necessary for games that aren't grid-based, because many of the holes in those games are either too small to fit through or large enough that there won't be any problem jumping/dropping through them.

I guess that's it for this post. I'm not sure if it's a particularly interesting one. Let me know if you have any special methods for improving the player's ease-of-movement in your games.

No comments:

Post a Comment