using UnityEngine; using System; public class respawn : MonoBehaviour { private GameObject player; [SerializeField] private Transform respawnPoint; private AudioSource audioSource; // Reference to the AudioSource component public AudioClip hurtSound; // The sound clip to be played void Start() { player = GameObject.Find("Frank"); audioSource = GetComponent(); } void Update() { } private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Player")) { try{ audioSource.PlayOneShot(hurtSound);} catch(Exception e){ ; } player.transform.position = respawnPoint.position; Debug.Log("Respawn: Move"); } } }