protected virtual void LoopFrictionPhysics()
{
// dynamic friction.
dx *= (1 - 0.04) - (controller.InputStates.Down ? 0.05 : 0);
dy *= (1 - 0.04) - (controller.InputStates.Down ? 0.05 : 0);
da *= (1 - 0.12);
// static friction.
dx -= dx > 0 ? Math.Min(0.01, Math.Abs(dx)) * Math.Sign(dx) : 0;
dy -= dy > 0 ? Math.Min(0.01, Math.Abs(dy)) * Math.Sign(dy) : 0;
da -= da > 0 ? Math.Min(0.01, Math.Abs(da)) * Math.Sign(da) : 0;
}