reverted HealthbarController to it's old glory
This commit is contained in:
parent
9c68e2dfcb
commit
1c2983053a
1 changed files with 11 additions and 4 deletions
|
@ -9,17 +9,22 @@ public class HealthbarController : MonoBehaviour {
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update() {
|
void Update()
|
||||||
|
{
|
||||||
// if player alive and spawned
|
// if player alive and spawned
|
||||||
if ( player != null ) {
|
if (player != null)
|
||||||
|
{
|
||||||
UpdatePointer(player.GetHealth());
|
UpdatePointer(player.GetHealth());
|
||||||
} else if (currentRotation != 0) {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//if player dead or not spawned
|
//if player dead or not spawned
|
||||||
UpdatePointer(0);
|
UpdatePointer(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdatePointer(float playerLife) {
|
void UpdatePointer(float playerLife) {
|
||||||
float offset = playerLife - currentRotation;
|
float offset = playerLife - currentRotation;
|
||||||
gameObject.transform.Rotate(Vector3.forward, offset);
|
gameObject.transform.Rotate(Vector3.forward, offset);
|
||||||
currentRotation += offset;
|
currentRotation += offset;
|
||||||
|
@ -27,5 +32,7 @@ public class HealthbarController : MonoBehaviour {
|
||||||
|
|
||||||
public void SetPlayer(Player ply) {
|
public void SetPlayer(Player ply) {
|
||||||
player = ply;
|
player = ply;
|
||||||
|
maxRotation = player.GetMaxHealth();
|
||||||
|
currentRotation = player.GetHealth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue