1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/HealthbarController.cs
2018-04-22 11:49:15 +02:00

29 lines
874 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthbarController : MonoBehaviour {
float currentRotation;
private Player player;
// Use this for initialization
void Start () {
player = GameController.instance.GetPlayer();
currentRotation = 100f;
}
// Update is called once per frame
void Update () {
// if player alive and spawned
if (player != null) {
gameObject.transform.Rotate(Vector3.forward, -(currentRotation - player.getHealth()));
currentRotation = player.getHealth();
} else {
//if player dead or not spawned
gameObject.transform.Rotate(Vector3.forward, -currentRotation);
currentRotation = 0f;
player = GameController.instance.GetPlayer();
}
}
}