Eonirr

Untitled

Feb 13th, 2026
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. using System.Collections;
  2. using UnityEngine;
  3.  
  4. public class HitFlash : MonoBehaviour
  5. {
  6.  
  7. [ContextMenu("FLASH")]
  8. public void Falsh()
  9. {
  10. SpriteRenderer sprite = GetComponent<SpriteRenderer>();
  11.  
  12. StartCoroutine(HitFlashing(sprite, 0.1f, Color.red));
  13. }
  14.  
  15. public IEnumerator HitFlashing(SpriteRenderer sr, float duration, Color flashColor)
  16. {
  17. Color original = sr.color;
  18.  
  19. sr.color = flashColor;
  20.  
  21. yield return new WaitForSeconds(duration);
  22.  
  23. sr.color = original;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment