It looks like you're new here. If you want to get involved, click one of these buttons!
Need help on this error:
NullReferenceException: Object reference not set to an instance of an object
Enemy.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Enemy.cs:41)
Code:
Answers
See if your object has collider or not.
Check if you have referenced the object in unity or not. You have not used a reference to the player or object or anything to which you are referencing. (as in the given image, I guess)
Do not use "tag.Equals", instead use other.gameObject.tag == "B". Also, in my opinion, try this in the if statement:
if ( other.collision.tag == "B") //Use collision instead of gameObject while refering in the collider.
Also you do not need to use "other.gameObject" in destroy script as it is horrible. Use this and refer it in unity:
Destroy (gameObject); It will destroy the object or the clone of it.
Hope it was helpful. If you like, please help me too.
https://forum.brackeys.com/discussion/2611/why-my-score-scirpt-works-on-all-of-my-prefabs#latest