Problem with my C# code (iTween)

Here is my code. In the logs i have “i am in the move02” but the itween path is not launching… i don’t know why…Could you help me ? (the move01 is working perfect because it’s my start…)

using UnityEngine;
using System.Collections;

public class Move_tuto : MonoBehaviour {
	
	int step = 1;

    void Update() {
		
		if(gameObject.transform.position.x == 3 && gameObject.transform.position.z == -3){
			step = 2;
		}
		if(gameObject.transform.position.x == 3 && gameObject.transform.position.z == -18)
			step = 3;
		
		if(step == 1){
			move01();
			step = 200;
		}
		if(step == 2){
			move02();
			step = 300;
		}
		
    }
	
	void move01(){
		iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("tuto"),"easetype", "linear", "delay", 1.20, "time", 1.04));
	}
	void move02(){
		iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("tutos"),"easetype", "easeOutCirc", "delay", 0.01, "time", 2.33));
		Debug.Log ("I am in the move02");
	}
	
}

I am sure for the path’s names. I added delay on the 2nd because it didn’t work…

I think the problem is you may have two iTweens with the same function (MoveTo) running at the same time. Only one function type of an iTween can be running on a gameobject at a time.

Solution: Stop any previous running iTweens before starting the new one. 1

void move02(){
	iTween.Stop(gameObject);
	yield WaitForSeconds(0.01); //stopping an iTween needs some sort of wait time before starting another one
	iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("tutos"),"easetype", "easeOutCirc", "delay", 0.01, "time", 2.33));
	Debug.Log ("I am in the move02");
	}

Since you are calling these iTweens in the Update function, just be sure you aren’t calling them while others are running, and if you are, be sure to stop all previous running iTweens.

Problem resolved.

if(gameObject.transform.position.x == 3 && gameObject.transform.position.z == -3){
         step = 2;
       }

The position is always X= 3 and Z = -3 so it’s calling move2() every frames and then the object can’t move. thanks anyway.