void applyAcceleration(Entity e, float deltaTime) { AccelerationComponent acceleration = e.acceleration; VelocityComponent velocity = e.velocity; acceleration.x = getAcceleration(acceleration.x, acceleration.frictionX, deltaTime); acceleration.y = getAcceleration(acceleration.y, acceleration.frictionY, deltaTime); velocity.vel += new Vector2(acceleration.x * deltaTime, acceleration.y * deltaTime); if (acceleration.stopNearZero) { // todo int count = 0; if (Mathf.Abs(velocity.vel.x) < EPSILON) { velocity.vel.x = 0.0f; count++; } if (Mathf.Abs(velocity.vel.y) < EPSILON) { velocity.vel.y = 0.0f; count++; } if (count == 2) { e.RemoveAcceleration(); } } }