So I made a script that will switch from one mode to another. I want to repeat this script forever but don’t know how. Can anybody help?
The script:
ArmAnim.attributes.add('ArmMode1', {type : 'entity'});
ArmAnim.attributes.add('ArmMode2', {type : 'entity'});
// initialize code called once per entity
ArmAnim.prototype.initialize = function() {
};
// update code called every frame
ArmAnim.prototype.update = function(dt) {
window.setTimeout( function(){
this.ArmMode1.enabled = false;
this.ArmMode2.enabled = true;
}.bind(this), 2000);
};
Hi @PhilipJeffrey!
Maybe something like below?
ArmAnim.attributes.add('ArmMode1', {type : 'entity'});
ArmAnim.attributes.add('ArmMode2', {type : 'entity'});
// initialize code called once per entity
ArmAnim.prototype.initialize = function() {
this.repeat();
};
ArmAnim.prototype.repeat = function(dt) {
window.setTimeout(function() {
this.ArmMode1.enabled = false;
this.ArmMode2.enabled = true;
this.repeat();
}.bind(this), 2000);
};
You probably also want to switch between the ArmMode. You can check with a statement which ArmMode is active. There is a better way, but I don’t know this off the top of my head.
1 Like
Thank so much! I will test it out!