[SOLVED] Timer Implementation

If i use the example provided from Will’s Code in the topic above, add a Boolean variable to toggle your timer by calling a function when you need to start your timer.

var Timer = pc.createScript('timer');

// initialize code called once per entity
Timer.prototype.initialize = function() {
    this.timer = 0;
    this.isTimerActive = false;
};

// Begin timer by calling this function
Timer.prototype.beginTimer = function(){
    this.isTimerActive = true;
};

// update code called every frame
Timer.prototype.update = function(dt) {
   if(!this.isTimerActive)
        return;

    this.timer += dt;

    if (this.timer > 10) {
        // 10 seconds has elapsed - do whatever you need here...

        // Reset the timer
        this.timer = 0;
        this.isTimerActive = false;
    }    
};