Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Blinking Sprite Renderer - Why Doesn't This Work?

$
0
0
My player is invincible for 2 seconds after taking a hit. I'm trying to make him blink during this time, but it's not happening visually, even though my code seems perfect to me.

The blinking code that doesn't work:
Code (CSharp):
  1.    
  2.  
  3. public bool isImmortal;
  4. [SerializeField] public float immortalityTime;
  5. [SerializeField] private SpriteRenderer sprite;
  6.  
  7. private IEnumerator Blink()
  8.     {
  9.         while (isImmortal)
  10.         {
  11.             sprite.enabled = false;
  12.         }
  13.         yield return...
Blinking Sprite Renderer - Why Doesn't This Work?

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>