The code with all the other bits taken out:
---
var lGround:Array;
function Start () {
var lGround= new Array();
}
function OnCollisionEnter(other:Collision){
if(other.gameObject.tag == "Ground"){
var gcontainer:GameObject=other.collider.gameObject;
print(gcontainer);
lGround.Add(gcontainer);
}
}
The print line returns (5x):
Cube (UnityEngine.GameObject)
UnityEngine.MonoBehaviour:print(Object)
Which seems to be the cube object. (There are five of them that it is falling into.)
I then get this error (5x):
NullReferenceException: Object reference not set to an instance of an object
Lemming.OnCollisionEnter (UnityEngine.Collision other) (at Assets/Scripts/Lemming.js:46)
How do I add the object colliding to an array properly?
↧