Skip to content
Snippets Groups Projects
Commit e062535d authored by billc27's avatar billc27
Browse files

fix: health slider bug (restore health orb)

parent 21cd95f3
1 merge request!31Fix Health Slider Bug (Restore Health Orb)
...@@ -2,14 +2,17 @@ using Nightmare; ...@@ -2,14 +2,17 @@ using Nightmare;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class RestoreHealthOrbs : Orbs public class RestoreHealthOrbs : Orbs
{ {
PlayerHealth playerHealth; PlayerHealth playerHealth;
Slider healthSlider;
public override void Start() public override void Start()
{ {
playerHealth = GameObject.Find("Player").GetComponent<PlayerHealth>(); playerHealth = GameObject.Find("Player").GetComponent<PlayerHealth>();
healthSlider = GameObject.Find("HealthSlider").GetComponent<Slider>();
// Destroy object after 5 seconds // Destroy object after 5 seconds
Destroy(gameObject, 5f); Destroy(gameObject, 5f);
...@@ -23,6 +26,9 @@ public class RestoreHealthOrbs : Orbs ...@@ -23,6 +26,9 @@ public class RestoreHealthOrbs : Orbs
playerHealth.currentHealth = 100; playerHealth.currentHealth = 100;
} }
// Set Health Slider
healthSlider.value = playerHealth.currentHealth;
// Destroy the orb // Destroy the orb
Destroy(gameObject); Destroy(gameObject);
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment