Hi there, is there a simple way in iTween to move an object and return it to it’s start position once? You can’t specify to only loop once with LoopType, MoveFrom changes the position of the object instantly (then moves it back to its start position).
I’m currently triggering an iTween script to take it to it’s destination and then using oncomplete to trigger a second to return it, but I feel like I’m missing an easy option?
Thanks!
So, if I’m understanding you correctly, you are doing something like this:
private void Move()
iTween.MoveTo(gameObject, iTween.Hash("position", destinationPosition, "oncompletetarget", gameObject, "oncomplete", "goBackToOriginal"));
}
private void goBackToOriginal() {
iTween.MoveTo(gameObject, iTween.Hash("position", originalPosition));
}
I’m pretty sure that’s the best/easiest method. I could think of other ways to do it but they seem more complicated. Like one method I thought of, is have a oncomplete call that toggles a boolean value and in your update have something like:
if(moveBackToOriginal)
iTween.MoveTo(gameObject, iTween.Hash("position", originalPosition));
But then I ask myself, why wouldn’t I just make the iTween call to move the object back in the oncomplete method? I couldn’t think of a valid answer to make it feasible.
I think you are good to go.
Hello, sorry for Necroposting(reply-ing on old post)
But i think u better go with direct movement…
i encountered this problem too, and here’s how i deal with it…
iTween.MoveTo(player, {"x":3,"time":1});//move to destination
iTween.MoveTo(player, {"x":-8,"time":1,"delay":1.5});//back to source position(-8)
and the object just go to x = 3 within range of 1 sec movement, and stopping there 1.5 before he get back to the initial position.
hope this helps 