When trying to do the Roll-a-ball tutorial, several issues were raised. Some of them are listed below:
- Get a NullReferenceException.
- Script error in the console window (Yellow triangle :The referenced script on this Behaviour is missing!)
- Want to add multiple levels to the game
- The sphere is not collecting the collectables, it goes through the cubes.
- You have written the Start() function without capital 'S' for the NullExceptionError or FixedUpdate without capital 'F' for the The referenced script on this Behaviour error. When you get a NullExceptionError, it means that there is a variable that is not being assigned. This is correct because the Start function is written incorrectly, therefore any variable supposed to be assigned in this function is not being called.
- You don't have a script assigned in the Script component.
- You are not aware of how to add levels to a game.
- The OnTriggerEnter function is written wrong.
- If you wrote the Start() function without capital 'S', then just change the 's' to a capital 'S'. It is that simple! If it happened to the FixedUpdate function, just do the same as with the Start() function. When you are programming, you have to be careful with typos and case is important. Also, please ensure that you write a semi colon (';) at the end of each line. On the other hand, if you wrote onTriggerEnter, just change it to OnTriggerEnter.
- Click the circle next to the right of the text field (Missing (Mono Script)) and below the gear icon and select the GameController script.
- Think of levels as Scenes. Therefore if you want to add a level, just create a new Scene. (Remember to save the one you were using before moving to the new scene). Before a level will load, you need to add it to the list of levels used in the game by using: File --> Build Settings and add the current scene to the build. Afterwards just add the following line of code to when you want to load the level:
This article applies to Unity versions 5.x