Strange Error with Itween PutOnPath
Dont hate, this is my first game. i only have high-school any advice is greatly appreciated CODE FIRST (without Error):
private Vector3 stuff;
private Vector3[] pathR;
private Vector3[] pathM;
private Vector3[] pathL;
private Vector3[] pathUR;
private Vector3[] pathUM;
private Vector3[] pathUL;
private Vector3[] pathDR;
private Vector3[] pathDM;
private Vector3[] pathDL;
private Vector3[] currPath;
public string strPath;
private float countTime= 0;
private float percent;
private bool move = false;
private bool possible = false;
private float timeFixed;
private float futurePercent;
private float futureRotate;
private float tempoTotal = 10f;
private float tempoTroca = 1f;
private float lookTime = 2f;
// Use this for initialization
void Start () {
//etc...
player = GetComponent<Transform> ();
alien = GetComponent<CharacterController> ();
cameraTransform = GameObject.FindGameObjectWithTag("MainCamera").transform;
//Adicionar propriedades aos caminhos
iTween.Hash("path", iTweenPath.GetPath("MidPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear );
iTween.Hash("path", iTweenPath.GetPath("LeftPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
iTween.Hash("path", iTweenPath.GetPath("RightPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
iTween.Hash("path", iTweenPath.GetPath("UpMidPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
iTween.Hash("path", iTweenPath.GetPath("UpLeftPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
iTween.Hash("path", iTweenPath.GetPath("UpRightPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
iTween.Hash("path", iTweenPath.GetPath("DownMidPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
iTween.Hash("path", iTweenPath.GetPath("DownLeftPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
iTween.Hash("path", iTweenPath.GetPath("DownRightPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);
//Caminhos em array
pathM = iTweenPath.GetPath ("MidPath");
pathL = iTweenPath.GetPath ("LeftPath");
pathR = iTweenPath.GetPath ("RightPath");
pathUM = iTweenPath.GetPath ("UpMidPath");
pathUL = iTweenPath.GetPath ("UpLeftPath");
pathUR = iTweenPath.GetPath ("UpRightPath");
pathDM = iTweenPath.GetPath ("DownMidPath");
pathDL = iTweenPath.GetPath ("DownLeftPath");
pathDR = iTweenPath.GetPath ("DownRightPath");
strPath = "mid";
currPath = pathM;
}
(...)
void LateUpdate(){
countTime += Time.deltaTime;
percent = (countTime / tempoTotal)-0.001f;
futurePercent =((tempoTroca+countTime) / tempoTotal)-0.001f;
futureRotate =(countTime / tempoTotal)+0.201f;
possible=false;
if (Input.GetKeyDown(KeyCode.LeftArrow)) {
if (strPath == "right") {
possible = true;
currPath = pathM;
strPath = "mid";
stuff = iTween.PointOnPath(iTweenPath.GetPath("MidPath"), futurePercent);
}
(...)
if (move == false || countTime > timeFixed) {
move = false;
iTween.LookUpdate (gameObject, iTween.Hash("looktarget", stuff, "time", lookTime));
if (countTime <= tempoTotal)
Error here--->iTween.PutOnPath (gameObject, currPath, percent);<----Error here
stuff = iTween.PointOnPath(currPath, futureRotate);
}
The following Error appears when i change "tempoTotal" value to 20 or above. i change nothing in the code only the "tempoTotal" value. anyone knows what error is this?
PS: the game still runs without error and does everything so far
IndexOutOfRangeException: Array index is out of range. iTween.Interp (UnityEngine.Vector3[] pts, Single t) (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:6708) iTween.PutOnPath (UnityEngine.GameObject target, UnityEngine.Vector3[] path, Single percent) (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:5495) PlayerMotor.LateUpdate () (at Assets/scripts/PlayerMotor.cs:355)
Your answer
Follow this Question
Related Questions
Unity C# array index is out of range 1 Answer
iTween Switching Paths 0 Answers
Array index is out of range (C#)? 1 Answer
Array index is out of range??? (Day Night Cycle Script) 1 Answer