Add knockback when attacking, fix animation state
This commit is contained in:
@@ -181,6 +181,8 @@ void entityUpdate(ecs_iter_t *it) {
|
||||
continue;
|
||||
}
|
||||
|
||||
f32 knockback = 1.0f;
|
||||
|
||||
// Attack update
|
||||
if (canAttack && ecs_has(ECS, other, Health) && ecs_has(ECS, other, Owner)) {
|
||||
Player otherPlayer = ecs_get(ECS, other, Owner)->player;
|
||||
@@ -202,6 +204,8 @@ void entityUpdate(ecs_iter_t *it) {
|
||||
|
||||
canAttack = false;
|
||||
unit[i].attackElapsed = 0.0f;
|
||||
|
||||
knockback = 3.0f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -209,6 +213,7 @@ void entityUpdate(ecs_iter_t *it) {
|
||||
// Physics update
|
||||
slowDown += 0.2f;
|
||||
Position dif = Vector2Subtract(otherPos, position[i]);
|
||||
dif = Vector2Scale(dif, knockback);
|
||||
dir = Vector2Add(dir, dif);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user