void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { Respawn respawn = other.gameObject.GetComponent <Respawn>(); respawn.SetCheckpoint(transform.position); } }