Hi, I’m trying to make an Array of game objects at Start found around an enemy using Physics.OverlapSphere,
i thought this script I’ve done would do it, but says on the second find -
NullReferenceException: Object reference not set to an instance of an object
If I remark out
concreteBarriers *= current.gameObject;*
it prints out all the names and numbers up to the 16 it finds, can someone point me in the right direction please.
function Start()
{
hide();
}
function hide()
{
var colliders : Collider[] = Physics.OverlapSphere (transform.position, lookForCoverRange);
var cover : GameObject[];
for (var current : Collider in colliders)
{
print(current.name + " Number " + i);
cover = current.gameObject;
i++;
}
}
You need to give a bit more information. If you double click on the error message in Unity, what line in Mono is highlighted? Where is concreteBarriers declared and initialized?
– robertbuSorry, I'll take that on board for next time, sure there will be lots of next times ..
– Griffo