using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(SpriteRenderer))] public class RecolorOnCollision : MonoBehaviour { public Color color; private SpriteRenderer spriteRenderer; void Awake() { spriteRenderer = GetComponent(); } void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Enemy") { spriteRenderer.color = color; } } }