Forum begins after the advertisement:


[Part 7] My Respawn button isnt working

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 7] My Respawn button isnt working

Viewing 2 posts - 21 through 22 (of 22 total)
  • Author
    Posts
  • #14535
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    So far, your code seems correct. So let’s start looking through your Scene’s inspector while in this death screen that can’t be removed. Please open up the Canvas and look through it’s inspector values while you are dead, as well as the respawn button under “Death Screen” for it’s event system to see if it still has the GameManager on it.

    I’ll also need you to manually deactivate the death screen during the bug and see if the player has respawned, thus meaning for some reason, only the DeathScreen is still active, or everything for the respawn did not function.

    Then, we’re going to need to see if all parts of the code are being called correctly, add print code’s to your GameManager.cs RespawnPlayer():

        public void RespawnPlayer()
        {
            if(bench.interacted) {
                respawnPoint = bench.transform.position;
            } else {
                respawnPoint = platformRespawnPoint;
            }
            playerController.Instance.transform.position = respawnPoint;
            print("player position set")
            StartCoroutine(UIManager.Instance.DeactivateDeathScreen());
            print("deactivate death called")
            playerController.Instance.Respawned();
            print("player called to respawn")
        }

    Then do the same for your UIManager.cs:

        public IEnumerator DeactivateDeathScreen() {
            print("UIman deactive started")
            yield return new WaitForSeconds(0.5f);
            deathScreen.SetActive(false);
            print("screen setactive false")
            StartCoroutine(sceneFader.Fade(SceneFader.FadeDirection.Out));
            print("fade called")
        }
    #14539
    Alex
    Level 10
    Former Patron
    Helpful?
    Up
    0
    ::

    Thank you for the quick responses! I checked the button, and you guessed it, the GameManager was not set in there, unlike in Cave 1. I totally missed out on that when trying to recreate the respawns in the other caves. Thank you so much everything works now!

Viewing 2 posts - 21 through 22 (of 22 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: