Hi. Thanks for reading this. Listen, I'm new to Unity and hope you pardon my possibly stupid question. Here's the breakdown:
I instantiate an instance of Drone. Then I push drone into a globalArray. When drone is pushed, it is a Transform object. Here's code:
var droneAmount:int = 10;
// When a collision happens destroy ourselves
// and spawn an explosion prefab instead
for(var i=0; i<droneAmount; i++){
var drone : Transform;
var explosion : Transform;
explosion = GameObject.Find("plDrone").transform;
drone = Instantiate(explosion, transform.position, transform.rotation);
drone.name = "drone" + i;
global.enemyList.push(drone);
global.enemyNames.push(drone.name);
print("INDIVID ENTITY " +drone);
So, this drone has health. I fire bullets that have colliders setup so OnTriggerEnter, it depletes drone's health. When the drone reaches 0 health, I destroy the child, and splice the info from appropiate arrays. Here's code:
rigidbody.freezeRotation = true;
var health:int = 10;
var go:GameObject;
function Start(){
iTween.moveTo(go,{"x":-3.634033, "y":29.86236, "z":70.46572, "time":10});
iTween.rotateTo(go,{"x":270, "y":270, "z":0});
}
function Update () {
//print(health);
if(health<=0){
var child : GameObject = GameObject.Find(name);
print(child);
Destroy(child);
var shootOff : GameObject = GameObject.Find("plTurrent");
var com0 = shootOff.GetComponent("SmoothLookAt_VarTarget");
com0.enabled = false;
for(i=0; i<global.enemyNames.length; i++){
if(child == global.enemyNames*){*
*global.enemyNames.splice(i, 1);*
*global.enemyList.splice(i, 1);*
*}*
*}*
*}*
*}*
*```*
_<p>On Line 21 of last code, "if(child == global.enemyNames*){", I know I'm not doing something right. I think I need to convert a Transform to a GameObject. Sorry if there's something glaringly obvious. Tired and stuck. Thanx.</p>*_