HPgroup 空物体
HP image 黑色
fill image 绿色
参考
https://www.bilibili.com/video/BV18e411s7NU?from=search&seid=9409549270261559632
血条面向摄像头
using UnityEngine;
public class UILookatplayer : MonoBehaviour {
private Camera refCamera;
private bool isFace = true;
private Transform mRoot;
private void Awake() {
refCamera = Camera.main;
mRoot = transform;
}
void Start() {
}
// Update is called once per frame
void Update() {
}
private void LateUpdate() {
Vector3 targetPos = mRoot.position + refCamera.transform.rotation * (isFace?Vector3.back:Vector3.forward);
Vector3 targetOrientation = refCamera.transform.rotation * Vector3.up;
mRoot.LookAt(targetPos, targetOrientation);
}
}