Blinking entity for a while on hitting an obstacle

I want to repeat this method for a while (2-3 seconds)

GameManager.prototype.onBlink = function()
this.entity.model.enabled = false;
setTimeout(() => { this.entity.model.enabled = true;}, 500);

Hi @yash_mehrotra,

You can use setInterval instead of setTimeout, but this isn’t recommended since those timers run on their own even when the window is minized.

Usually you can setup a timer of your own in the update method of your script. Here is a useful post with some example code:

And also you can use the PlayCanvas tween library to execute code that animates/repeats things: