Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Enemy : MonoBehaviour {
- SpriteRenderer spriteRenderer;
- void Start()
- {
- spriteRenderer = GetComponent<SpriteRenderer>();
- }
- public void ReceiveHit()
- {
- StartCoroutine("Blink", 2);
- }
- IEnumerator Blink(int count)
- {
- for(int i = 0; i < count; i++)
- {
- spriteRenderer.color = new Color(0.5f, 0,0);
- yield return new WaitForSeconds(0.05f);
- spriteRenderer.color = Color.red;
- yield return new WaitForSeconds(0.05f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment