I currently working thought this guys youtube tutorial series “Lets clone a Pokemon Game”[Tutorial][1] and I keep getting this “ArgumentOutOfRangeException: Argument is out of range. Parameter name: index” And for the life of me I can’t figure out why? As far as I can tell my code looks just like his.
#pragma strict
import System.Collections.Generic;
//All Enemies
var AllMonsters : monster[];
var enemyMonster : monster;
var monsterEquipped : monster;
function Start () {
}
function OnGUI ()
{
var other : Player_stats;
other = gameObject.Find("_Player").GetComponent(Player_stats);
if(other.isInCombat)
{
GUI.Label (Rect(50, 100, 200, 100), ""+enemyMonster.name);
GUI.DrawTexture(Rect(70, 100, 128, 128), enemyMonster.image);
}
}
function Update ()
{
}
function randomizeMonster ()
{
var other : Player_stats;
other = gameObject.Find("_Player").GetComponent(Player_stats);
var tempMonsters : List.<monster> = new List. <monster>();
var randomNum : int = Random.Range(0,100);
if(randomNum == 20)
{
for(var i = 0; i < AllMonsters.Length; i++)
{
if (AllMonsters_.rarity == Rarity.rare && AllMonsters*.regionLocated == other.region)*_
* {*
_ tempMonsters.Add(AllMonsters*);
}
}
}
else*
* {
for(var j = 0; j < AllMonsters.Length;j++)
{
if(AllMonsters[j].rarity == Rarity.common && AllMonsters[j].regionLocated == other.region)
{
tempMonsters.Add(AllMonsters[j]);
}
}
}*_
* var newRandom = Random.Range(0, tempMonsters.Count);*
* enemyMonster = tempMonsters[newRandom];*
}
_*[1]: Unity Lets Clone a Game [ Pokemon ] - Part 14 - YouTube