You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
796 B
37 lines
796 B
using UnityEngine; |
|
|
|
namespace Game |
|
{ |
|
public class HealthBar : MonoBehaviour |
|
{ |
|
[SerializeField] private float _xOffset = 2.5f; |
|
[SerializeField] private Transform _target; |
|
[SerializeField] private float _scale = 1.5f; |
|
|
|
public void OnEnable() |
|
{ |
|
SetPercent(1); |
|
} |
|
|
|
public void SetPercent(float percent) |
|
{ |
|
_target.localScale = new Vector3(percent * _scale, _target.localScale.y, _target.localScale.z); |
|
_target.localPosition = new Vector3(_xOffset - _xOffset * percent, _target.localPosition.y, _target.localPosition.z); |
|
} |
|
|
|
private void Update() |
|
{ |
|
transform.rotation = Quaternion.identity; |
|
} |
|
|
|
private void FixedUpdate() |
|
{ |
|
transform.rotation = Quaternion.identity; |
|
} |
|
|
|
private void LateUpdate() |
|
{ |
|
transform.rotation = Quaternion.identity; |
|
} |
|
} |
|
}
|
|
|