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

32 lines
833 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;
float maxRotation;
2018-04-22 01:15:56 +02:00
private Player player;
// Update is called once per frame
void Update() {
2018-04-22 11:45:12 +02:00
// if player alive and spawned
if ( player != null ) {
UpdatePointer(player.getHealth());
} else if (currentRotation != 0) {
2018-04-22 11:45:12 +02:00
//if player dead or not spawned
UpdatePointer(0);
2018-04-22 11:45:12 +02:00
}
}
private void UpdatePointer(float playerLife) {
float offset = playerLife - currentRotation;
gameObject.transform.Rotate(Vector3.forward, offset);
currentRotation += offset;
}
public void SetPlayer(Player ply) {
player = ply;
}
2018-04-22 01:15:56 +02:00
}