I’ve browsed through the responses to previous instances of this problem and I cannot find an answer that resolves the error in my own script. So I am re-posting what I know is a common and probably obvious error. Thanks in advance for the help.
The errors begin toward the bottom, beginning with the line that says
" }else(attackElf.tag == “youngElf”)"
import System.Linq;
private var availablePositions : List.<Transform>;
//Allows assignation through the Inspector of the two possible positions from which the Spawn function will
//later randomly select.
var blackElves : GameObject[];
//Populates array with enemy elves
var fatElfCompanion : GameObject;
var shortElfCompanion : GameObject;
var strongElfCompanion : GameObject;
var smartElfCompanion : GameObject;
var fastElfCompanion : GameObject;
var toughElfCompanion : GameObject;
var uglyElfCompanion : GameObject;
var youngElfCompanion : GameObject;
//links each enemy elf with a partner
function Start ()
{
availablePositions = attackPositions.ToList();
}
//lists available attack positions of enemy elf and his partner.
function Update () {
}
function OnTriggerEnter(col : Collider)
{
if(col.gameObject.tag == "Player")
{
yield new WaitForSeconds(3.0);
Spawn;
}
}
//When player enters this zone, the function "Spawn" is called after three seconds.
function Spawn ()
{
var position = availablePositions[Random.Range(0, availablePositions.Length)];
availablePositions.Remove(position);
//One position is selected at random from two possibilities. The position selected is removed from set of possibilities.
var attackElf = Instantiate(blackElves[(Random.Range(0, blackElves.Length))], position.position, Quaternion.identity);
//One of the enemy elves is selected from the array and named "attack Elf". It is assigned to the randomly selected position.
if(attackElf.tag == "fatElf")
{
var companionElf = Instantiate(fatElfCompanion, availablePositions[0].position, Quaternion.identity);
}else if(attackElf.tag == "shortElf")
{
var companionElf = Instantiate(shortElfCompanion, availablePositions[0].position, Quarternion.identity);
}else if(attackElf.tag == "strongElf")
{
var companionElf = Instantiate(strongElfCompanion, availablePositions[0].position, Quaternion.identity);
}else if(attackElf.tag == "smartElf")
{
var companionElf = Instantiate(smartElfCompanion, availablePositions[0].position, Quaternion.identity);
}else if(attackElf.tag == "fastElf")
{
var companionElf = Instantiate(fastElfCompanion, availablePositions[0].position, Quaternion.identity);
}else if(attackElf.tag == "toughElf")
{
var companionElf = Instantiate(toughElfCompanion, availablePositions[0].position, Quaternion.identity);
}else if(attackElf.tag == "uglyElf")
{
var companionElf = Instantiate(uglyElfCompanion, availablePositions[0].position, Quaternion.identity);
}else(attackElf.tag == "youngElf")
{
var companionElf = Instantiate(youngElfCompanion, availablePositions[0].position, Quaternion.identity);
}
}
//A second, "Companion Elf" is instantiated at the other remaining position. It is not selected at random. It
//must be the concomitant of the "Attack Elf" previously selected.