Hey Drew apologies for the delayed response.
For the “hit flash” I set up a Coroutine which is triggered in the OnTriggerEnter2D event of the entity. The entity (in this case the player or the enemy plane) has a “hit” material, which is pure white, and a “default” material, which is the default sprite, serialized and assigned in the editor. The Coroutine simply accesses the Sprite Renderer and sets the white hit material and returns to the default after a tweak-able variable assigned as “hitLength”.
So the code looks like this for me:
[SerializeField] float hitLength = 0.5f;
[SerializeField] Material Default;
[SerializeField] Material Hit;
private void OnTriggerEnter2D(Collider2D other)
{
StartCoroutine(HitAnimCoroutine());
}
IEnumerator HitAnimCoroutine() // flashes player white when hit
{
GetComponent<SpriteRenderer>().material = Hit;
yield return new WaitForSeconds(hitLength);
GetComponent<SpriteRenderer>().material = Default;
}
There were other ways I discovered but this made most sense for my use.
I hope it helps!