My health bar locations are off unless unit is facing north.
Health bars are facing the camera. but not always on top of the units.
Without the FaceCamera script the hp bar always stay on top of my unit.
my code for facecamera.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FaceCamera : MonoBehaviour
{
// Start is called before the first frame update
Transform mainCameraTransform;
void Start()
{
mainCameraTransform = Camera.main.transform;
}
// Update is called once per frame
void LateUpdate()
{
transform.LookAt(
transform.position + mainCameraTransform.rotation * Vector3.forward,
mainCameraTransform.rotation * Vector3.up);
}
}
HealthBar settings: