Ive made the script right and everything works out until u launch… When u launch the health bar appears below your body and doesnt follow the camera:
But when im in the editor it works just fine:

Here ive looked for the problem for the past 2-3 hours and cant seem to find ANY problem and ik how to do this but something is off but eberything checks out if anyone can find an issue let me know
var Health = pc.createScript('health');
// initialize code called once per entity
Health.prototype.initialize = function() {
this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this);
this.app.keyboard.on(pc.EVENT_KEYUP, this.onKeyUp, this);
this.scaling = 0;
this.add = 0.25;
this.subtract = -0.1;
this.initialScale = this.entity.getLocalScale();
this.cameraEntity = this.app.root.findByName('CameraPlayer');
};
// update code called every frame
Health.prototype.update = function(dt) {
var currentScale = this.entity.getLocalScale();
if (currentScale.x < 0.01)
{
currentScale.x = 0;
}
if (currentScale.x > 50)
{
currentScale.x = 50;
this.scaling = 0;
}
{
this.scaling = 0;
}
currentScale.x -= this.scaling;
this.entity.setLocalScale(currentScale);
};
because im gonna take a break ill be back soon if u can help i thank u very much!
Nathan Hawkins!
https://playcanvas.com/editor/scene/722434