Enable Function not Working

Hello again! The this.entity.enabled function is not working and when its supposed to enable in the script using a variable, it won’t enable. I’m sure the variable part is right because I used console.error to let me know the variable is working. Thank you!

var Walk = pc.createScript('walk');


var move2 = 1;

// initialize code called once per entity
Walk.prototype.initialize = function() {

};

// update code called every frame
Walk.prototype.update = function(dt) {
    if (move2 === 0) {
    this.entity.enabled = true;
    this.entity.translateLocal(0, -0.10, 0)
    }

    if (move2 === 1) {
        this.entity.enabled = false;
    }

};

Hello @SoySauceStudios :wave:

If entity is disabled then its script is not running.
Try to enable the entity from other external script then you can access to its current script.

1 Like

Ohhhhh ok I understand now. Thank you!

1 Like