You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: