From 1c2983053ac30bd74a7d520d8f8de2f35ec9d697 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 23 Apr 2018 21:24:53 +0200 Subject: [PATCH] reverted HealthbarController to it's old glory --- Assets/Scripts/HealthbarController.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/HealthbarController.cs b/Assets/Scripts/HealthbarController.cs index ac96532..54b5bb5 100644 --- a/Assets/Scripts/HealthbarController.cs +++ b/Assets/Scripts/HealthbarController.cs @@ -9,17 +9,22 @@ public class HealthbarController : MonoBehaviour { private Player player; // Update is called once per frame - void Update() { + void Update() + { // if player alive and spawned - if ( player != null ) { + if (player != null) + { UpdatePointer(player.GetHealth()); - } else if (currentRotation != 0) { + } + else + { //if player dead or not spawned UpdatePointer(0); + } } - private void UpdatePointer(float playerLife) { + void UpdatePointer(float playerLife) { float offset = playerLife - currentRotation; gameObject.transform.Rotate(Vector3.forward, offset); currentRotation += offset; @@ -27,5 +32,7 @@ public class HealthbarController : MonoBehaviour { public void SetPlayer(Player ply) { player = ply; + maxRotation = player.GetMaxHealth(); + currentRotation = player.GetHealth(); } }