diff --git a/game/systems/s_entity.c b/game/systems/s_entity.c index f188825..781d928 100644 --- a/game/systems/s_entity.c +++ b/game/systems/s_entity.c @@ -181,7 +181,10 @@ void entityUpdate(ecs_iter_t *it) { continue; } - f32 knockback = 1.0f; + // Physics update + slowDown += 0.2f; + Position dif = Vector2Subtract(otherPos, position[i]); + dir = Vector2Add(dir, dif); // Attack update if (canAttack && ecs_has(ECS, other, Health) && ecs_has(ECS, other, Owner)) { @@ -204,17 +207,14 @@ void entityUpdate(ecs_iter_t *it) { canAttack = false; unit[i].attackElapsed = 0.0f; - - knockback = 3.0f; + if (ecs_has(ECS, other, Velocity)) { + Velocity *otherVelocity = ecs_get_mut(ECS, other, Velocity); + *otherVelocity = Vector2Add(*otherVelocity, Vector2Scale(Vector2Normalize(dif), 4000 * dt)); + } } } - // Physics update - slowDown += 0.2f; - Position dif = Vector2Subtract(otherPos, position[i]); - dif = Vector2Scale(dif, knockback); - dir = Vector2Add(dir, dif); } if (stationary) {