Lesson 46 – Dealing with Null References

A “Null Reference” happens whenever there is a reference to an object in code that doesn’t exist. This can happen if the object is not initialized with the “new” keyword, or if the object is destroyed in memory. The latter case is the problem we’re facing whenever the Cube object gets “eaten” and we destroy it with GameObject.Destroy(CubeReference). In this lesson we look at how to fix null references in general, and in this particular case, by creating a more interesting “Game Over” scenario.

Members Only Content (Source Code, Quiz, Q&A)

This content is for Extended Support Package members only.
Log In Register