Hi there, I am trying to add 2 Gameobjects to an GameObject array, but it says it :
Assets/WeaponScripts/SentryGun_plr.js(33,22): BCE0022: Cannot convert ‘UnityEngine.GameObject’ to ‘UnityEngine.GameObject’
In the latter code it takes a GameObject and finds the closest one.
So, how to I add 2 Gameobjects to an GameObject array.
function FindClosestEnemy (): GameObject {
var moblist : GameObject[];
moblist = E1 && E2;
var closest: GameObject;
var distance = Mathf.Infinity;
var position = transform.position;
for (var mobcheck : GameObject in moblist) {
var diff = (mobcheck.transform.position - position);
var curDistance = diff.sqrMagnitude;
if (curDistance < distance) {
closest = mobcheck;
distance = curDistance;
}
}
return closest;
}
E1 and E2 are FindWithTags.