Skip to content
Snippets Groups Projects

Fix Health Slider Bug (Restore Health Orb)

Merged Bill Clinton requested to merge feat/cheats-and-orbs into main
Compare and
1 file
+ 6
0
Preferences
Compare changes
@@ -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);
}
}