Do you know how I would us a variable (Collision2D collision) in the first function & put it in the WaitForSeconds Function? Any help would be nice.
GameObject go;
go = collision.gameObject;
Destroy(go);
Re-write your code to the following
void OnCollisionEnter2D(Collision2D collision)
{
switch (collision.gameObject.tag)
{
case "EnemyDog":
StartCoroutine(DestroyLazerAfterDelay(collision, 1f));
break;
case "Player":
break;
default:
break;
}
}
public IEnumerator DestroyLazerAfterDelay(Collision2D collision, float delay)
{
yield return new WaitForSeconds(delay);
Destroy(collision.gameObject);
}