I have this method which makes the game object in my scene go between right to left:
public void MoveAcrossXPlane()
{
iTween.MoveTo(_cubeObject, iTween.Hash("position", new Vector3(1, 1, 0), "speed", speed, "looptype", iTween.LoopType.pingPong));
}
A boolean is the only flag I got that can trigger this method. But when I set the boolean to false the method still keeps going and I want it to stop. How do I make it to where I click on the button I make the object move and when I hit it again the object stops?
You can use iTween.Stop() or iTween.StopByName() to stop your iTween. For StopByName(), you will need to add a name to your iTween.Hash pairs. Stop() stops all iTweens. If you plan on starting a new iTween in conjunction with stopping the current one, read the iTween reference concerning the timing of stops and the addition of new iTweens.
Note if you don’t need anything more complex from iTween that this MoveTo(), consider coding this your self or use the MoveObject scrip from the Wiki. It would give you a bit more control concerning stopping and starting.