I am trying to make it so that when 3 of a type of object come into contact, all are destroyed in a function Burst(). Here is what I have so far:
var touchCount : int;
function Start (){
touchCount = 0;
}
function OnCollisionEnter(collision : Collision){
if(collision.gameObject.name == this.gameObject.name){
touchCount++;
if(touchCount>=2){
for (var contact : ContactPoint in this){ //THIS IS WHERE THE ERROR IS COMING FROM
contact.thisCollider.gameObject.SendMessage("Burst", null, SendMessageOptions.DontRequireReceiver);
Burst();
}
}
}
}
The error I get whenever 3 of the objects touch, as they’re meant to, is: ApplicationException: Argument is not enumerable (does not implement System.Collections.IEnumerable).
Boo.Lang.Runtime.RuntimeServices.GetEnumerable (System.Object enumerable)
UnityScript.Lang.UnityRuntimeServices.GetEnumerator (System.Object obj)
ballScript.OnCollisionEnter (UnityEngine.Collision collision) (at Assets/scripts/ballScript.js:20)
Would love a solution to this problem, as this has been bugging me for ages!
Thanks, in advance