public void Attack(int dmg) //damage player { DamageScreen.SetActive(true); playerHealth -= dmg; hpBar.SetHP(playerHealth); hpBar.UpdatePlayerBar(); //Debug.Log("HEALTH: " + playerHealth); Invoke("DisplayDamage", 0.1f); timeCheck = Time.time; }
// Update is called once per frame void Update() { if (Time.time > abilityUp) //Used to check whether the time conditions for the defensive ability are met { if (Input.GetKeyDown(KeyCode.U) && PlayerStats.playerHealth <= 100) //allows the player to activate shield with the U key only if the player is at 100 health or lower { PlayerStats.playerHealth += 50; abilityUp = Time.time + cooldownDefensive; print("defensive ability used"); currentHP = PlayerStats.playerHealth; HealthBar.SetHP(currentHP); HealthBar.UpdatePlayerBar(); } } }