I’m making a 2d platformer and I’m looking for something like the Shantae games where instead of having lives the player to falls off cliffs and loses a heart after respawning to the stage. I have the game over and respawn system set, but the player ends up recovering lost health after the respawn as opposed to losing.
Please help!
My kill script: `using UnityEngine;
using System.Collections;
public class KillPlayer : MonoBehaviour {
public Player player;
// Use this for initialization
void Start () {
player = FindObjectOfType<Player> ();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other) {
if (other.tag == "Player") {
player.Death ();
player.Damage (1);
}
}
}`
and my respawn code: `public void Respawn () {
StartCoroutine (“RespawnCoroutine”);
}
//Routine for respawn dalay time
public IEnumerator RespawnCoroutine() {
gamePlayer.gameObject.SetActive (false);
yield return new WaitForSeconds (respawnDelay);
gamePlayer.transform.position = gamePlayer.respawnPoint;
gamePlayer.gameObject.SetActive (true);
}
}
`