Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using UnityEngine;
- public class HitFlash : MonoBehaviour
- {
- [ContextMenu("FLASH")]
- public void Falsh()
- {
- SpriteRenderer sprite = GetComponent<SpriteRenderer>();
- StartCoroutine(HitFlashing(sprite, 0.1f, Color.red));
- }
- public IEnumerator HitFlashing(SpriteRenderer sr, float duration, Color flashColor)
- {
- Color original = sr.color;
- sr.color = flashColor;
- yield return new WaitForSeconds(duration);
- sr.color = original;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment