using UnityEngine; public class PlayerRespawn : MonoBehaviour { private static Vector3 respawnPoint; private void Start() { // Set respawn position to the last saved point or the starting position if (respawnPoint == Vector3.zero) { respawnPoint = transform.position; // Initial spawn point } else { transform.position = respawnPoint; // Respawn at last checkpoint } } public void SetRespawnPoint(Vector3 newRespawnPoint) { respawnPoint = newRespawnPoint; } public void Respawn() { transform.position = respawnPoint; // Reset any necessary player state here } }