[SOLVED] Making A Health Bar Tutorial, BUT


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;

because im gonna take a break ill be back soon if u can help i thank u very much!
Nathan Hawkins!


Do you mean in the editor itself or when you launch the scene to test from editor? Can you post a link to a public project that shows this issue please?




As far as I can tell, the health bar is not in the camera view:



Click launch then look at the screen and u will see. Dont move the camera when u launch


Just looks like this to me:


Looks like this for me


@yaustar Now it should be completely gone right? even if u look around its not there? Fixed now ty


Looks fine now



Yup ty for your help