Using generalised direction for facing direction

Using the input for facing direction is great when moving. But not so great when releasing input.

The problem is expressed when we using WASD, travel diagonally (e.g. W+D keys), and then release. If both keys were released simultaneously within input thresholds, the last vector input would be the same as the travel direction.

But if one key was released a bit earlier or later, it the last input vector would be one of the vectors. Hence, you get a jarring result where the character is moving diagonally, then stops to face in a slightly different direction.

To overcome this, a generalised direction (or vector) is tracked when the character is moving, and is updated half-a-second (or less). This direction is used only when the character has stopped moving and is going to choose which direction it is facing.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.