Add knockback when attacking, fix animation state
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user