0
using UnityEngine;
using System.Collections;

public class MainMenu : MonoBehaviour
{

    public Transform EnemyManager;
    public Transform Player;
    Animator anim;

    public void startgame() 
    {
        anim.SetTrigger("GameStart");
        EnemyManager.gameObject.SetActive(true);
        Player.gameObject.SetActive(true);
    }
}

I'm trying to make a start button for a game. I want the start button to run this script but every time I press start the game freezes and I get this error. I looked all night and can't figure out how to solve it.

Paweł Marecki
  • 632
  • 1
  • 9
  • 19
  • 1
    I can't see anywhere where you instantiate the class members... – Justin Harvey Sep 12 '16 at 07:46
  • 2
    animator is not initialized. Do `anim = GetComponent();` in the Start function before using it. – Programmer Sep 12 '16 at 07:50
  • I'm not exactly sure how to use this site, but Justin Harvey that solved my problem. I started doing all this a day ago with no prior experience what so ever. Thanks for your help, I really appreciate it. If there is a way I can vote you up some how just let me know and I will get it done. – Eric Deering Sep 12 '16 at 08:06
  • I don't know if this reply is to Justin or me but you can't upvote anything except for comments because your reputation is not enough. You can only accept answers with your current reputation but you cannot for now because this question is closed as a duplicate. Happy coding! – Programmer Sep 12 '16 at 10:16

0 Answers0