9/25/2012

Finetuning character movement

At the end of Iteration 001, the character movement felt odd in more then one situation:

  • Character got stuck at the of blocks
  • First jumping and moving while in air did not work
  • Character "floated" along ceilings while jumping
  • Movement did not ease out but came to a sudden stop once the controller was released
Let's start with this problems caused by "not reading the manual"... again.

When the character got stuck at the edge of a block it looked like this:


A close look in the scene showed, that regarding Unity everything was quite in order. The character controllers capsule rested savely on the edge. However the little blocky man refused to move even the slightest bit to the right.


The solution to this problem was to simply adjust the "step offset" property. A higher offset allows the character to climb steeper steps. So movement to the right was blocked because the default virtual leg length of one was far to short for my scene. More information on can be found in the Character Controllers API docs.

A step offset of 10 works quite well
The rest of my evening was consumed by finetuning the PlatformerController.js borrowed from the 2D Gameplay Tutorial
  1. In air controls did not work as I expected. I added two additional properties in order to set a minimum and maximum in air velocity:

  2. Collision with a block above did not end the current jump as vertical speed was not set to zero. The inversion of vertical speed on collision did the trick:

  3. My first iteration on character animation did not include the adaption of animation speed based on movement speed. I fixed this writing two additional lines of code and once again loved unity for it's simplicity:

I end todays post with one of my favorite quotes:

Dans ses écrits, un sàge Italien
Dit que le mieux est l'ennemi du bien.
~Voltaire

Having said this, character movement feels good enough for me for today :)

No comments:

Post a Comment