Trying to create a script that can turn textures on/off at the rate of each change tanking place every 0.25 seconds. Since you cannot use yield/coroutines in the update function what is the next best course of action?
In my mind the easiest way to do this was to create an update function like this :
function Update ()
{
if (ButtonStates.BLINK == 1)
{
ButtonStates.Button_1 = 1;
{
if (ButtonStates.BLINK == 0)
{
ButtonStates.Button_1 = 0;
}
}
Now i just need to be able to turn BLINK on and off every 0.25 seconds. Looking around i found a few things that might work but cant seem to implement them. InkvokeRepeating?
If the on time and off time were the same, I’d use this:
function Blink () {
particleEmitter.emit = !particleEmitter.emit;
}
Then do “InvokeRepeating(“Blink”, wait, wait);” In that case you can also use CancelInvoke at any time without having to code extra logic, which is nice. Any time you find yourself with objects that need to be in different states at different times, dump Update and use coroutines or InvokeRepeating or whatever.
Thank you guys very much for the quick reply. My only confusion on your reply, even tho i understand it completely is… how do you set Blink to be true? or false? I have not dealt with the use of “while” before as im just learning scripting as i go currently.
Thanks again!
Edit:
Hah sorry i think i got it, i just needed to setup some type of condition, not use the words true or false. My mistake, still learning