using System.Collections; using System.Collections.Generic; using UnityEngine; public class Checkpoint : MonoBehaviour { public Transform SpawnAt; public Sprite inactiveSprite; public Sprite activeSprite; bool active = false; public static GameObject activeCheckpoint; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } private void OnTriggerEnter2D(Collider2D collision) { if(collision.tag == "Player" && !active) { active = true; GetComponent().sprite = activeSprite; PlayerHealth pHealth = collision.gameObject.GetComponent(); pHealth.spawnPosition = SpawnAt.position; if(activeCheckpoint != null) { activeCheckpoint.GetComponent().active = false; activeCheckpoint.GetComponent().sprite = inactiveSprite; } activeCheckpoint = gameObject; } } }