void OnTriggerEnter2D(Collider2D collider) { if (collider.CompareTag("Train")) { Destroy(Instantiate(impactEffect, transform.position, Quaternion.identity), 3f); Destroy(gameObject); PlayerTrain.DamageTrain(damage); } }