Enemy healthbar, what is the best way to make it?

Hello,

I got little problem with my healthbar that i made for my enemy objects.

made 3 planes

  • 1 border
  • 1 hp background
  • hp bar

all got halo settings, and that gives me a problem.

They all face correctly to the camera, but when i walk around the enemy the planes turns inside eachother becouse the privot points are not at the same locations. (else you wont see all 3 planes).

screenshot of the problem:

How can i solve this problem? or how do you make healthbars for enemies?
(you make just 1 obj with the 3 planes and use bone for it to animate or how do i need to look at it?)

any more info about that would be great, thank you.

Cotax

Hello
if your plane objects are “parent” to the camera, no need to add the “halo” function!
One other way to make “health bars” its with a “add overlay scene actuator”.
Bye

Why is the object origin not at the same position?

Disable halo, switch to normal face orientation and make the border plane track to camera with python or SCA actuator. Parent the health bar objects to the border plane so they turn with it.

Here’s my python script to attach to border plane to make it turn to face camera:


#sprite.py
import bge.logic

cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()

cam = scene.active_camera
    
camv = cont.owner.getVectTo(cam)
cont.owner.alignAxisToVect(camv[1],2,1)

For the player hp i am using an overlay scene (hud)
but this is for the enemies, how u do that with an overlay?

MonsterWhy is the object origin not at the same position?

becouse of the depth factor, 3 planes at the same position results in 1 plane showed wjile the others are “inside it”.
so i moved them like 1 mm back.

Disable halo, switch to normal face orientation and make the border plane track to camera with python or SCA actuator. Parent the health bar objects to the border plane so they turn with it.

Here’s my python script to attach to border plane to make it turn to face camera:

Code:
#sprite.py
import bge.logic

cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()

cam = scene.active_camera

camv = cont.owner.getVectTo(cam)
cont.owner.align

parent hp bar to camera?
thats not what i want, it gets parented to the enemy.
becouse i got plenty of enemies to fight against then i cannot parent it to the camera right? becouse of the enemy/hpbar location?

cant try atm, but ill try some things out when i am at home.

You can try having the HP bar copying camera’s orientation at a certain offset which makes it “face” the camera.

You can move them in edit mode. Tjus way they can have the origin at the same location.

If you cant manage that. Simply use an empty that tracks the camera (tracktoActuator) and parent the objects to this empty.

I’m not telling you to parent it to camera. Please. I’ve done this kind of healthbar myself and I know what you are trying to make.

Disable halo. Parent your border plane to the enemy as you probably have. Attach always sensor to border plane and have it run that python script. Parent your background and hp bar to the border plane.

Sorry miss read OTO’s post, my bad.

The script looks good, but i didnt try it, got it working by moving the planes in edit mode (i didnt even think about moving it there xD) or is using the script a better thing to do compared to halo settings?

Thanks everyone

Ok, I thought Halo mode would be per-face using face midpoint for rotating but apparently it uses object origin as well. Good.

I’ve never actually got the Billboard/Halo working myself (any tips?) so ATM I’m turning everything by python. Halo/Billboard is more efficient and you should use it if it works for you :slight_smile:

I’ve never actually got the Billboard/Halo working myself (any tips?)

sure,

ok make a plane.
select it, tab, R , x, 90. then R, z, 90.
add material and put the facing on billboard or halo.
and it should work.

every blender version works difrend with these settings.
Does above not work (you dont see your plane when hitting p)
then go to edit mode and rotate the plane 90c on the z axis. ( keep doing this until it works :slight_smile: )

it works kinda strange but through that way u can make it vissible and it tracks nicely to the camera.
if you want a blend file let me know and ill make one for you.