Ok so I was hoping that when these to objects go collide or in my case enter trigger that they roll a dice and which ever is lower it gets deleted! Here my code.
#pragma strict
var Dice = 0;
Dice = Random.Range(1,100);
private var anotherScript : SunDele;
function OnTriggerEnter(slr : Collider) {
anotherScript = slr.GetComponent(SunDele);
if (anotherScript.Dice > Dice) {
Destroy (gameObject.transform.parent.gameObject);
}
}
Now I have put rigedbody on both and enabled trigger enter but I get the error: NullReferenceException: Object reference not set to an instance of an object SunDele.OnTriggerEnter (UnityEngine.Collider slf) (at Assest/SunDele.js:8)
However it did do what I wanted it to do (I can see through the editor) but it pause the game and gives me that error. plz help