::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.