O'Reilly logo

Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation by James A. Henley, Matthew Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Exceptions

Exceptions are the glaring errors thrown by problematic code. They show themselves in the Unity Console, which provides us with a snippet of information about the error and a link to the script line where it encountered the error.

Open the PlayerController script and scroll down to the following line:

float move = Input.GetAxis("Horizontal");

Remove a letter from the word "Horizontal". Any letter. Take your pick. We know that the line is no longer correct, but the script is still going to build because there are no syntax errors present. Save the script, return to Unity, and run the game. You’ll find that the Console is immediately plagued with error messages like those seen in Figure 5.5.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required