using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; public class PlayerHealth : MonoBehaviour { public float health = 100f; EnterDoor spawn; // Update is called once per frame void Update () { if (health <= 0) { OnLevelWasLoaded(); } } //allow the player to only be hurt by the enemy void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Enemy") { Debug.Log("hit"); health = health - 1; } } void OnLevelWasLoaded() { spawn.player.transform.position = spawn.spawnPoint[EnterDoor.spawnPointIndex].position; } }