using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerStats : MonoBehaviour { public GameObject dieParticles; public Vector2 checkpoint; bool firstTime = true; void OnEnable(){ if (!firstTime){ Respawn(); Invoke("EnableCameraCollider", 2f); }else{ firstTime = false; } } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void Die() { AudioManager.instance.Play("Hit"); Instantiate(dieParticles, transform.position, Quaternion.identity); Camera.main.GetComponent().isTrigger = true; GetComponent().velocity = Vector2.zero; GetComponent().canMove = false; FindObjectOfType().Die(); } void Respawn(){ transform.position = checkpoint; GetComponent().canMove = true; } void EnableCameraCollider(){ Camera.main.GetComponent().isTrigger = false; } }