Unityにおいて制作を行っているのですが、
「ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index」というエラーが出てしまいました。
このエラーの改善方法について教えて頂けると嬉しいです。
C#
1using UnityEngine; 2using System.Collections; 3using System.Collections.Generic; 4 5public abstract class EnemyBase : GameActor { 6 7 [SerializeField] 8 private PlayerMover player; 9 [SerializeField] 10 protected float tweenTime = 0.05f; 11 [SerializeField] 12 public enum EnemyStatas 13 { 14 Enemy, 15 Enemy1, 16 } 17 public EnemyStatas type; 18 19 20 public enum State 21 { 22 Moving, 23 MoveEnd, 24 } 25 26 public State state = State.Moving; 27 public State GetState { get { return state; } } 28 29 protected ANode node = null; 30 31 protected Vector3 nextPosition = Vector3.one; 32 protected Vector3 currentPosition = Vector3.one; 33 34 35 public abstract void Init(); 36 public abstract void Proc(); 37 public abstract void Finish(); 38 public abstract void Dead(); 39 40 41 public void AIMoveDirAStar() 42 { 43 FieldManager.Instance.GetGroundLayer.SetParam(X, Z, (int)ObjectType.None); 44 var path = FieldManager.Instance.FindPath(X, Z, player.X, player.Z); 45 46 if(path == null) { return; } 47 48 nextPosition = new Vector3(path[1].x, 1, path[1].z); 49 } 50 51 public List<Point2D> FindPath(int xStart, int zStart, int xGoal, int zGoal) 52 { 53 var pList = new List<Point2D>(); 54 var astar = new ANodeManager(FieldManager.Instance.GetGroundLayer, xGoal, zGoal); 55 var node = astar.OpenNode(xStart, zStart, 0, null); 56 if (node == null) 57 { 58 Debug.LogError("スタート地点が不正です"); 59 return null; 60 } 61 62 astar.AddOpenList(node); 63 64 int cnt = 0; 65 while (cnt < 1000) 66 { 67 astar.RemoveOpenList(node); 68 astar.OpenAround(node); 69 70 node = astar.SerchMinScoreNodeFromOpenList(); 71 if (node == null) 72 { 73 Debug.LogError("袋小路なので終了"); 74 return null; 75 } 76 if (node.X == xGoal && node.Z == zGoal) 77 { 78 astar.RemoveOpenList(node); 79 node.GetPath(pList); 80 pList.Reverse(); 81 return pList; 82 } 83 } 84 Debug.LogError("なんもねえ"); 85 return null; 86 } 87 public virtual void Move() 88 { 89 90 } 91 public virtual void AnimationEnd() 92 { 93 94 } 95 public virtual void Attack(PlayerMover pl) 96 { 97 98 } 99}
AIMoveDirAStar()の中の
nextPosition = new Vector3(path[1].x, 1, path[1].z);
でエラーを吐いているみたいです。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/28 01:41
2016/11/28 02:51
2016/11/30 04:10