I am making a script that lets an airplane choose the city it will land in, using an array.
This is what I have-
#pragma strict
var allcities : Array; //an array of all the cities on the map
var takeoff : String; //where the plane has taken off from
var landing : GameObject; //where the plane will land
function Start () {
allcities = GameObject.FindGameObjectsWithTag("City"); //putting all the cities on the map into an array
var i = Random.Range(0, allcities.Length);
landing = allcities*;*
}
However, when I run the script, the landing var in the inspector remains the same. No errors or warnings occur, just the script does not seem to function. I threw in some Debug.Log’s, but I cannot seem to find the problem.
Before that, I had condensed the script to this-
#pragma strict
var allcities : Array; //an array of all the cities on the map
var takeoff : String; //where the plane has taken off from
var landing : GameObject; //where the plane will land
function Start () {
- allcities = GameObject.FindGameObjectsWithTag(“City”); //putting all the cities on the map into an array*
- landing = allcities[Random.Range(0, allcities.Length)];*
}
The only reason I broke it up was so that I could find the problem easier.
Any ideas?
Only Javascript please
Fairly Urgent