Fix slowdown
This commit is contained in:
@@ -207,7 +207,7 @@ void entityUpdate(ecs_iter_t *it) {
|
||||
}
|
||||
|
||||
// Physics update
|
||||
slowDown += 0.1f;
|
||||
slowDown += 0.2f;
|
||||
Position dif = Vector2Subtract(otherPos, position[i]);
|
||||
dir = Vector2Add(dir, dif);
|
||||
}
|
||||
@@ -218,9 +218,16 @@ void entityUpdate(ecs_iter_t *it) {
|
||||
velocity[i] = Vector2Subtract(velocity[i], dir);
|
||||
}
|
||||
|
||||
slowDown = BZ_MIN(slowDown, 0.2f);
|
||||
slowDown = BZ_MIN(slowDown, 0.65f);
|
||||
if (!stationary && slowDown > 0.0f) {
|
||||
velocity[i] = Vector2Scale(velocity[i], 1 - slowDown);
|
||||
f32 speed = Vector2Length(velocity[i]);
|
||||
slowDown = 1 - slowDown;
|
||||
f32 maxSpeed = unit->maxSpeed * slowDown;
|
||||
|
||||
if (speed > maxSpeed) {
|
||||
Vector2 norm = Vector2Normalize(velocity[i]);
|
||||
velocity[i] = Vector2Scale(norm, maxSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user