- Home /
Making child rotation/position independent of that of parents'
Hello,
I have a player object that rotates, and I want a health bar to hover over it. When I make the health bar a child of the player object, it rotates with a player. Now, I know how to make the health bar just follow the player through scripting, but I still want to place the health bar under the player object for organization purpose.
Is there a way to achieve this?
Thanks!
Answer by robertbu · Feb 28, 2014 at 07:51 PM
You can attach a script to the object that rotates it to face the correct direction in LateUpdate(). Assuming the child starts out facing the correct direction, your code might be as simple as:
var rotation : Quaternion;
function Start() {
rotation = transform.rotation;
}
function LateUpdate() {
transform.rotation = rotation;
}
I'm not sure of your application. You may want something that billboards only on the 'y' axis, or something that points at the camera (rather than just has the same rotation).
Your answer
![](https://koobas.hobune.stream/wayback/20220613135026im_/https://answers.unity.com/themes/thub/images/avi.jpg)