I want to run metod in the class from another class and both of them atached to different obj
Two classes. the first is:
public class NewScore: MonoBehaviour {
public void updateScoreBy( int intr) {
Debug.Log("intr+4"+intr+4);
}
}
and the second is:
public class NewPlus: MonoBehaviour {
public NewScore newscore;
public void OnTriggerEnter2D(Collider2D obj) {
newscore.updateScoreBy(+1);
}
}
When I run my code I recive an arror "NullReferenceException: Object reference not set to an instance of an object" and it points on newscore.updateScoreBy(+1); How can I fix it?