- Home /
How do I make it so only one player spawns when I respawn?
I'm making a 2d platformer and I just recently got a death and respawn mechanic however when it respawns it makes 2 of the character for some reason and that happens every time it dies.
Level Manager: public class LevelManager : MonoBehaviour{ public static LevelManager instance; public Transform respawnPoint; public GameObject Chip;
private void Awake() { instance = this; } public void Respawn () { Instantiate(Chip, respawnPoint.position, Quaternion.identity); } }
Death: public class DeathScript : MonoBehaviour { private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Spikes")){ Destroy(gameObject); LevelManager.instance.Respawn(); } } }
Your answer
Follow this Question
Related Questions
How to make a companion that trails character moves, and not collide? 0 Answers
How do I make it so it spawns 1 clone instead of 2? 2 Answers
Why is my raycast projecting from the middle instead of the bottom? 0 Answers
Why does my character pass through walls when he respawns and I lose control of him? 2 Answers
How to share varibles betweent scripts 4 Answers