Question
I have a game and it shows me this error Object reference not set to an instance of an object Game.Start() when moving to
I have a game and it shows me this error Object reference not "set to an instance of an object Game.Start() " when moving to the next page and it appears that the reason for the error is this command: anim =character.GetComponent
public class game: MonoBehaviour { public AudioSource A, b; [SerializeField] private string SceneNameToLoading; public GameObject character; Animator anim;
void Start() { A.Play(); b.Stop(); anim = character.GetComponent
public void win() { b.Play(); A.Stop(); anim.SetBool("walk", true); GiveSticker(); StartCoroutine("nextlevel");
} public void loss() { anim.SetBool("cry", true); }
IEnumerator nextlevel () { yield return new WaitForSeconds(5); SceneManager.LoadScene(SceneNameToLoading); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started