Repeating Functions

last time i asked this question i didnt get the code right.

can someone tell me how to repeat a function, i need it for camera movement.
i need to repeat this.entity.translatelocal(0,0,0). i could use some help plz

Maybe loops are what you’re looking for? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration

Put it in the update function. It should work.

1 Like

Something like this:

MyScript.prototype.movement = function() {
   this.entity.translateLocal(0,-0.1,0);
}

MyScript.prototype.update = function(dt) {
    this.movement();
};

can i make it repeat only a certain amount of times

That would be something like this:

MyScript.prototype.update = function(dt) {
    this.timer += dt;

    if (this.timer < 3) {
        this.movement();
    }
};