I'm creating a 2D top-down shooting game. I want to add a damage effect to the enemy when the bullet collides with it.
Is there a way to turn the collided sprite white for 0.5 seconds and then fade out to the normal sprite.
void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.tag == "Enemy")
{
EnemyController enemy = collision.transform.GetComponent<EnemyController>();
if(enemy != null)
{
// Take the actual damage
enemy.TakeDamage(damage);
// Change sprite color temporarily here
}
}
}