How to add a child to an object without combining transforms

Im currently working on a game where i have multiple enemies that have health. Since unity’s gui system is poor, i have a skinny rectangle and a label displaying its level that will follow the enemy where ever it goes, but the issue is that the enemy will turn from left to right cause the label and rectangle to flip with it. I want the label and rectangle to stay constantly above his head wherever he goes so i was just going to set it in code to stay above his head… but to do that i would want the two other objects to be as a child of the main enemy so that i can add multiple enemies and not have the script get confused on which label or rectangle to use… So is there a way to have the two other objects be child of the main enemy without having them move with him automatically? Also is there a better way to approach what im trying to achieve? It seems like this is getting complex for a seemingly simple task.

Child objects are always positioned relative to their parents. To resolve your problem, you could make a new, empty gameobject and make enemy, label and rectangle all children of it (which would keep them together in the hierarchy).

Then, to keep the score and label tracking the enemy, have a script on the score that references the corresponding enemy position (var pos = transform.parent.Find(“Enemy”) or something like that), and then manually set the transform.position equal to the position of the enemy each Update() loop.

You need a 3D text.

  1. Add a 3D text to your enemy as child.

  2. Create a script say “FaceCamera” and attach it to the 3D text

  3. Then add this to “FaceCamera” script

    void Update()
    {

    transform.LookAt( Camera.main.transform );
    

    }