Hello people,
I am quite the newbie and I am completely stuck on a problem. I did quite some googling for an answer, but didn’t succeed in finding the answer. This is my 3rd day I am trying to solve this.
I am trying to make a very basic game. I made a mission generator script who generates an assignment for the player to fly to in a chopper.
I am placing empty gameobjects all over the world with a script on it which defines it’s name (nameCountry) and area of influence (range). The variables are being pushed in to an array.
#pragma strict
var range:float;
var nameCountry:String;
function Start () {
var myNode: CountryNode = new CountryNode(transform.position,range,name);
GameObject.Find("Main Camera").GetComponent(CountryDistanceCheck).countryNodes.push(myNode);
}
In a second script I want to test if the chopper is within the range of one of those GameObjects, so I am trying to match the name of all the objects in the array with the name of the assigment.
#pragma strict
var countryNodes= new Array();
var target: Transform;
var loopHandle :boolean = true;
var missionDestination:String;
class CountryNode {
var position:Vector3;
var range: float;
var nameCountry: String;
function CountryNode ( position:Vector3, range:float,name:String ){
this.position = position;
this.range =range;
this.nameCountry = name;
}
}
function Update () {
target = GameObject.Find("Helicopter").transform;
missionDestination = GameObject.Find("MissionMaker").GetComponent(MissionGeneratorV2_).destinationX;
//Debug.Log(missionDestination);
for ( var i =0; i < countryNodes.length; i++){
//var Country : GameObject= countryNodes*;*
_ Debug.Log(countryNodes*);_
_ //Debug.Log(CountryNode(i).nameCountry);_
_ Debug.Log(countryNodes.length);*_
* }*
}
I am iterating through the array of the empty GameObjects. But it keeps on saying that countryNodes*.nameCountry doens’t exist. While my debug checks do confirm I pushed the objects into the array.*
Can somebody help me how to check the names of my objects in this array. It keeps saying nameCountry is not a member of object. Why o why?