- Home /
percentage bar parented to a moving rotating object
I am currently trying to create a percentage bar (health, completion, statPercentage). I found one implementation that uses 2 planes, and then re-sizes the more forward one, to have it look like a percentage meant for a 2D game where objects never rotate. but where if the objects used to display this percentage would be parented to an object that can rotate this causes problems, and beyond that the game takes place in a 3D space where any given face of the parent can be facing the camera, and be proxy this plane system would need to be adjusted.
I know that I could probably get away with this by using GUI, but I would much rather use the plane method so that is is not always on the topmost draw layer.
how could I implement this type of percentage bar system so that the percentage bar:
move with the object.
is always upright even when the object is rotated.
is always facing the camera.
Answer by AVividLight · Apr 16, 2013 at 10:00 PM
Hey Gardian06,
Maybe I'm misunderstanding your question, but could you parent the panes to the main camera?
If it's clear I don't understand, please let me know so I can modify my answer.
I hope this helps! -Gibson
but if these objects were created dynamically then a reference to each object would have to be given as needed.
Answer by Dracorat · Apr 16, 2013 at 10:02 PM
What about:
progressObject.LookAt(camera);
... in each Update step.
??
To make it move with the object, just make it a child of the object.
Ok, it looks like that works for the orientation, but the issue I have with making it a child of the object is that the objects can also rotate freely about any axis meaning that the progressObject would orient itself with the parent, so I think my options are either to adjust orientation each frame (if they are children), or adjust position each frame (if they are independent)
though if they were independent then if these objects they were referencing were created dynamically they would also have to create their own progressObject to maintain reference.
Just make sure to orient the parent object first, then do the lookAt camera for the progress object. The easiest way is to get a reference to the progress object inside the update loop of the parent - move the parent, then "look" the progress - all inside the same update call.
Your answer
![](https://koobas.hobune.stream/wayback/20220613100443im_/https://answers.unity.com/themes/thub/images/avi.jpg)