There is a code that should, in a collision, send the same value to other scripts. But he gives an error. Here is the actual code itself:
void OnCollisionEnter2D (Collision2D collision) { if (collision.gameObject.name == "plat1") { delete1 plat1 = collision.gameObject.GetComponent<delete1>(); plat1.Hit(plusone); delete2 plat2 = collision.gameObject.GetComponent<delete2>(); plat2.Hit(plusone); delete3 plat3 = collision.gameObject.GetComponent<delete3>(); plat3.Hit(plusone); } Here is the error code:
NullReferenceException: Delplusone.OnCollisionEnter2D (UnityEngine.Collision2D collision) Object Reference (at Assets / scripts / ScriptsPlus / delplusone.cs: 17)
What can be wrong? Thanks in advance for your help!