Forum begins after the advertisement:


[Part 7] Death respawn screen always on screen

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 7] Death respawn screen always on screen

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #15732
    Sanket Pise
    Participant
    Helpful?
    Up
    0
    ::

    View post on imgur.com


    here is the fade time for the Screen Fader

    #15733
    Joseph Tang
    Moderator
    Helpful?
    Up
    0
    ::

    Hmm, yea this seems weird to me.

    Well, I’m not confident in fixing this issue as i don’t know why your scene fader takes so long to come out.

    However, let’s try some things.


    First, can you try swapping out all WaitForSeconds() to WaitForSecondsRealtime() in the following methods and scripts:

    Player.cs

        IEnumerator Death()
        {
            pState.alive = false;
            Time.timeScale = 1f;
            GameObject _bloodSpurtParticles = Instantiate(bloodSpurt, transform.position, Quaternion.identity);
            Destroy(_bloodSpurtParticles, 1.5f);
            anim.SetTrigger("Death");
    
            yield return new WaitForSeconds(0.9f);
            StartCoroutine(UIManager.Instance.ActivateDeathScreen());
        }

    UIManager.cs

        public IEnumerator ActivateDeathScreen()
        {
            yield return new WaitForSeconds(0.8f);
            StartCoroutine(sceneFader.Fade(SceneFader.FadeDirection.In));
    
            yield return new WaitForSeconds(0.8f);
            deathScreen.SetActive(true);
        }

    If this works, it might mean that when you died, the game slowed down/time stopped.


    Second, you can try changing the code in SceneFader to this:

    SceneFader.cs

        void SetColorImage(ref float _alpha, FadeDirection _fadeDirection)
        {
            fadeOutUIImage.color = new Color(fadeOutUIImage.color.r, fadeOutUIImage.color.g, fadeOutUIImage.color.b, _alpha);
    
            _alpha += Time.deltaTime * (1 / fadeTime) 0.2f * (_fadeDirection == FadeDirection.Out ? -1 : 1);
        }

    Otherwise, let me think about some other possible reasons why your scenefader is so late.

    #15734
    Sanket Pise
    Participant
    Helpful?
    Up
    0
    ::

    Yeah the WaitForSecondsRealtime() fixed the delay for me

    #15735
    Joseph Tang
    Moderator
    Helpful?
    Up
    0
    ::

    If that fix worked, then that means that your HitStopTime() is activated when you get hit and die.

    This should technically be fine since it’s not game impacting but just a choice of aesthetics if you want time to slow down on the last hit or not.

    This is especially the case since now that we changed the code to Realtime, the death screen will come up no matter what.

Viewing 4 posts - 16 through 19 (of 19 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: