I’m currently getting this error.
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.GameObject].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
Gaskin_G015877f.Controllers.NewCombatAI.combatAction () (at Assets/Mods/Gaskin_G015877f/NewCombatAI.cs:220)
NoxCore.Controllers.AIStateController.processState () (at Assets/Custom Scripts/Controllers/AI/AIStateController.cs:111)
NoxCore.Controllers.AIStateController+<update>c__Iterator0.MoveNext () (at Assets/Custom Scripts/Controllers/AI/AIStateController.cs:85)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
From this code.
if (structure.scanner.isNewSweep() == true)
{
Gui.setMessage("scanning");
frontTargets.Clear();
shieldedTargets.Clear();
potentialMissileTargets.Clear();
// group1 finds a target
List<Weapon> weapons = group1.getAllWeapons();
Weapon weap1 = weapons[2];
foreach (GameObject target1 in structure.scanner.getEnemiesInRange())
{
TurretSocket turretSocket = weap1.Socket as TurretSocket;
Vector3 pos = turretSocket.transform.position;
Vector3 forward = turretSocket.transform.TransformDirection(0, 1, 0);
if (Vector3.Dot(forward, (target1.transform.position - pos)) >= Mathf.Cos(turretSocket.fireArcHalf))
{
frontTargets.Add(target1);
}
}
group1.setTarget(frontTargets[0]);
// group1 stops here
//group2 finds a target
if (missileTarget == null)
{
foreach (GameObject target2 in structure.scanner.getEnemiesInRange())
{
if (Vector3.Distance(target2.transform.position, transform.position) <= 1000)
{
potentialMissileTargets.Add(target2);
}
}
missileTarget = potentialMissileTargets[0];
}
else
{
if (ammoRequired == 0)
{
ammoRequired = (missileTarget.GetComponent<Structure>().MaxHullStrength / 100);
}
group2.setTarget(missileTarget);
}
//group2 stops here
//group3 finds a target
foreach (GameObject target3 in structure.scanner.getEnemiesInRange())
{
if (target3.GetComponent<StaticTarget>() != null)
{
if (target3.GetComponent<StaticTarget>().AllShieldsFailed != true)
{
shieldedTargets.Add(target3);
//Gui.setMessage("found shielded target");
}
}
if (shieldedTargets.Count > 0)
{
group3.setTarget(shieldedTargets[0]);
}
}
//group3 stops here
from what I understand its to do with a list somewhere not having any content but I’m not sure which one. the lists here aren’t manipulated anywhere else within the code so something here is causing the issue.
Any help would be appreciated.