Health system for ratbots, can now stab ratbots

This commit is contained in:
2024-10-20 00:40:53 -07:00
parent d8c8e88220
commit 81b0797774
4 changed files with 135 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ public class Ratbot : MonoBehaviour
public float moveSpeed;
public float damageStrength;
public float damageTimeoutSeconds;
public float health = 10;
float lastDamageTime;
GameState gameState;
GameObject player;
@@ -29,4 +30,10 @@ public class Ratbot : MonoBehaviour
lastDamageTime = Time.fixedTime;
collision.gameObject.GetComponent<Teo>().health -= damageStrength;
}
public void Damage(float hurtyAmount) {
health -= hurtyAmount;
if (health <= 0) {
Destroy(gameObject);
}
}
}