well well…i have got a problem getting my level controller to destroy an object by it´s name.
first of all i set my obect´s name to it´s id
this.name = gameObject.GetInstanceID().ToString();
missileID = int.Parse(this.name);
//Debug.Log(this.name+" / "+missileID);
after that i search for the lvl controller by it´s tag…
LvLcontroller : GameObject = GameObject.FindWithTag("LevelController");
… on a trigger event ( the missile hits it´s target) i send the id/name of the missile to the lvl controller by using:
LvLcontroller.SendMessage("DestroyFunction", missileID);
the value “arrived” at the controller an initializes this:
function DestroyFunction(missileID){
//ObjToDestroy.name = missileID.ToString();
Debug.Log(missileID);
Destroy(GameObject.Find(missileID));
}
InvalidCastException: Cannot cast from source type to destination type.
is the result.
so whats wrong with this idea?