I fixed your EnemyUI class

Using identity means it takes the rotation of the parent. That is bad and messes up the facing. You want it reset to zero. So I fixed it like so.

public class EnemyUI : MonoBehaviour
{
    // Work around for Unity 2018's lack of nested prefabs
    [Tooltip("The UI canvas prefab")]
    [SerializeField] GameObject EnemyCanvasPrefab;

    Camera CameraToLookAt;

    void Start()
    {
        CameraToLookAt = Camera.main;
        Instantiate(EnemyCanvasPrefab, transform.position, transform.rotation, transform);
    }

    void LateUpdate()
    {
        transform.LookAt(CameraToLookAt.transform);
    }
}
2 Likes

Thanks Zimmer.
The bar wasn’t rotating for me before i put your change in, now it does.

My pleasure! Happy to help.

That was bugging me. Thanks for the fix.

Privacy & Terms