The character controller has always been instant. As in, when you press a button, you will move at full speed straight away and also rotate to face the right direction instantly. I'm not the biggest fan of slidy controls on a game, but I also realised that instant movement isn't great either. So I've gone for a compromise of having acceleration, deceleration and rotational speed, but only a bit. And by only a bit, I mean you accelerate fast, you decelerate even faster and turn pretty fast. The acceleration and deceleration were simple to implement, it's the same equation as the jumping and gravity equation (http://finalgame15.blogspot.co.uk/2015/05/physically-based-jumping-character-motor.html).
The turn was a little trickier. Not the rotating it part, the non rotational movement part. Sticking with my instant reaction philosophy, I want the motor to seem as responsive as possible whilst still having smoothed turning. This isn't an issue until you reach the near 180 degree turn mark. Then you want things to change. You don't really want the player to be moving forward during a near 180 degree turn. Imagine if you were near an edge and you press back to turn around and stop yourself. If you still moved forward whilst turning, you may end up falling off the edge. Ideally you want to start moving away from the edge. So what I did is this, when a 180 turn is detected, you first stop moving instantly, and then start to accelerate in the target direction of the turn.
This image will help demonstrate this. The top example shows what happens if you are facing forward and you move forward. You will move forward relative to the player (blue arrow). The bottom image shows what happens if you were facing forward, then triggered a 180 turn. You would stop (unless you were already still). Then start to accelerate in the direction of the blue arrow whilst also turning towards the desired direction. You would only start moving if you were still holding a direction. Otherwise you do the turn on the spot.
These three features really add to the feel of the motor. I think I have found a good balance for them to achieve my smooth but responsive feel!

0 comments:
Post a Comment