Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Null reference exception for player object when trying to ignore collision

$
0
0
Actually, there are two problems here, but here's the first and main problem -

I have an enemy class where I am attempting to ignore collision with the player.

In the enemy class I have -

Code (CSharp):
  1. public GameObject player;
  2.  
  3.     private void Start()
  4.     {
  5.         player = GameObject.FindGameObjectWithTag("Player");
  6.  
  7.         Physics2D.IgnoreCollision(player.GetComponent<Collider2D>(), GetComponent<Collider2D>());
  8.     }
  9.  
There is a null reference exception as soon as I hit the...

Null reference exception for player object when trying to ignore collision

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>