void OnTriggerEnter(Collider col)
{
if (m.Target == null)
{
if (col.gameObject.tag == “Player”)
{
Debug.Log(“found player”);
m.Target = col.transform;
}
}
}
So I have this code where I want to set a player as a target as long as there is no target.
Target is a Transform.
The problem I have here is that it gives me NullReferenceExceptions on the check.
So what do you guys think as a possible solution. How to do this?