1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/HealthbarController.cs

30 lines
874 B
C#
Raw Normal View History

2018-04-22 01:15:56 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthbarController : MonoBehaviour {
2018-04-22 11:45:12 +02:00
float currentRotation;
2018-04-22 01:15:56 +02:00
private Player player;
// Use this for initialization
2018-04-22 11:45:12 +02:00
void Start () {
player = GameController.instance.GetPlayer();
currentRotation = 100f;
2018-04-22 01:15:56 +02:00
}
// Update is called once per frame
void Update () {
2018-04-22 11:45:12 +02:00
// 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();
}
2018-04-22 01:15:56 +02:00
}
}