Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 5 - Player Script - Page 164 #19

Open
r2klabs opened this issue Nov 24, 2019 · 0 comments
Open

Chapter 5 - Player Script - Page 164 #19

r2klabs opened this issue Nov 24, 2019 · 0 comments

Comments

@r2klabs
Copy link

r2klabs commented Nov 24, 2019

After adding the following code:

Item hitObject = collision.gameObject.GetComponent().item;

when I run the game, the character collides with an Coin object and it disappears as it is supposed to. However, before moving the character, the Console prints the following message:

NullReferenceException: Object reference not set to an instance of an object
Player.OnTriggerEnter2D (UnityEngine.Collider2D collision) (at Assets/Scripts/MonoBehaviours/Player.cs:12)

I checked several times to see if I missed a previous step, but I don't think I have. I am not sure if this issue will cause problems later in the book; I wanted to resolve before I moved on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant