I'm trying to make a nice controls for my game, but I can't achieve enough SMOOTHNESS.
if (kbState.GetPressedKeys().Length != 0 && _direction != Vector2.Zero)
{
_direction.Normalize();
_position += _direction * (_speed * (float)gameTime.ElapsedGameTime.TotalSeconds);
}
else
_direction = Vector2.Zero;
if (kbState.IsKeyDown(Keys.W))
{
_direction += new Vector2(0, -1f);
}
if (kbState.IsKeyDown(Keys.S))
{
_direction += new Vector2(0, 1);
}
if (kbState.IsKeyDown(Keys.D))
{
_direction += new Vector2(1, 0);
}
if (kbState.IsKeyDown(Keys.A))
{
_direction += new Vector2(-1, 0);
}
There is the code. Could you help me a little and give an advice how to make character stop smoothly. I tried many options, but could'nt find any that fit.