Remove controllable instead of checking health

This commit is contained in:
Askou
2021-06-17 10:29:29 +02:00
parent 811e478ca9
commit 6ca2b90291
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -82,6 +82,9 @@ namespace BBM
.addComponent<HealthComponent>(1, [](WAL::Entity &entity, WAL::Wal &) {
auto &animation = entity.getComponent<AnimationsComponent>();
animation.setAnimIndex(5);
if (entity.hasComponent<ControllableComponent>())
entity.removeComponent<ControllableComponent>();
if (entity.hasComponent<TimerComponent>())
return;
entity.addComponent<TimerComponent>(1s, [](WAL::Entity &entity, WAL::Wal &wal) {
@@ -22,7 +22,7 @@ namespace BBM
auto health = entity->tryGetComponent<HealthComponent>();
Vector2f move = controllable.move.normalized() * controllable.speed;
if (health->getHealthPoint() <= 0)
if (health && health->getHealthPoint() <= 0)
return;
movable.addForce(Vector3f(move.x, 0, move.y));
}