5
« on: March 02, 2016, 02:24:29 PM »
Hello. I have attempted to implement Flash SetEase for DOColor for a couple of different situations, but in both cases, problems occur if it is started again when it is already in progress.
In my first case, I attempted to make an enemy flash white briefly upon being hit, by changing the material renderer color. If it is hit twice in a row, the object will permanently stay white and never go back to the original color.
In the second case, I tried to make an outline in the UI blink for a few moments when health is restored. However if it happens while the flashing is already activated, the flash rate will appear to be on white twice as much, which is expected. However after the flashing stops, the next time the flashing is activated it will retain the undesired double white period, and the problem can be repeated until it will only appear as solid white with no flashing.
The code used is below, it is fairly straightforward.
Case 1:
rend.material.DOColor(Color.white, 0.02f).SetEase(Ease.InFlash, 4, 0);
Case 2:
Color whiteopaque = new Color32(255,255,255,255);
Text.GetComponent<Outline>().DOColor(whiteopaque, 1.6f).SetEase(Ease.InFlash, 28, 0);
I thought of putting a bool there to prevent the flash from reactivating, that would reset after OnComplete, but I want a new activation to reset the flashing duration instead, so to do that I had to use a coroutine instead of the SetEase to get the functionality I want.
However, I was wondering if you have any suggestions or if DoTween has any built in functionality to prevent the double flashing / stuck white problem, or a way of adding to the timer that I am not aware of. I would like to use DoTween if it is possible! Thank you very much for any advice!