Flashback with loading scene

Hello Everyone,

I’d like to know how to make a flashback effect. So far, I have it so if you set off the trigger you will load the new scene. But before the scene loads, I’d like there to be a flash then the scene loads. Thanks for any help.

@Legend458

The easiest and IMHO best way would be to do that before you do the LoadScene() call.

The following is just one example of a flashback in the form of an animation using an Animator trigger and animation called “PlayFlashBack” (note: The Loop Time checkbox of the animation must be unchecked)

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class FlashBackHandler : MonoBehaviour
{
    private Animator animator;

    void Start()
    {
        animator = gameObject.GetComponent<Animator>();
    }

    void LevelComplete()
    {
        StartCoroutine(StartFlashBack());
    }

    IEnumerator StartFlashBack()
    {
        if (animator != null)
        {
            // play the animation using SetTrigger() - this must be setup in the Animator
            animator.SetTrigger("PlayFlashBack");

            // whaile the animation is playing
            while (animator.GetCurrentAnimatorStateInfo(0).IsName("PlayFlashBack"))
            {
                yield return new WaitForSeconds(0.01f); 
            }
        }
        yield return new WaitForSeconds(0.01f); 
        SceneManager.LoadScene("NextSceneToLoad");
    }
}

Mavina, there are errors in the code. See my above comment.