Enemy Health bar does not rotate after switching scenes


#1

@yaustar Sorry to call on you but when i load the Health Bar tutorial scene on its own the health bar rotates with the camera so you can always see the health it is at. but when i load through main menu it no longer rotates… here is the code i use to make it rotate (Update Function)

this.entity.setRotation(this.camera.getRotation());

if you find out why this is happening let me know ive tryed everything i could but couldnt figure out why this is happening
Project if needed: https://playcanvas.com/editor/scene/722434


#2

I don’t know the specifics, but if you want something to lookAt something, you can use lookAt. Here you want a healthbar to always look at the camera right? So you can use:

this.entity.lookAt(this.camera.getPosition());

the same is done in the example with the halo: https://developer.playcanvas.com/en/tutorials/light-halos/

Maybe this helps


#3

Yes it helps thank you :slight_smile: but it doesnt help sorry makes the nHealth dissappear sorry :slight_smile: thanks anyway