- Home /
Question by
cofstudios · May 11, 2020 at 08:24 AM ·
c#scripting problemvideocutscenereferences
Loading scene makes the references in that scene null
Hello. I am making my first game and I'm trying to load the first level of it when the cutscene at the start ends. I don't know if it's possible to make the script do something after a video clip ends, so I wrote my code like this:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class CutsceneEnd : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
StartCoroutine("wait");
}
IEnumerator wait()
{
yield return new WaitForSeconds(36);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
But the problem is not with my method of waiting for the end of the video, it's with the scene it loads. I can't move my character because all the references in the scripts are null. I have no idea what I did wrong.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612233900im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Video streaming from unity 0 Answers
How to dynamically construct a reference to a game object by name 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers