How to get Tween to ping pong back to original position?

0 favourites
  • 4 posts
From the Asset Store
Calculate parabolic trajectories and tween objects over them.
  • I'm trying to use a Tween to slide a ui element into view from off screen, then back out again. However, I cannot figure out how to get the Tween to perform the second part right.

    I am checking if a boolean has a value and starting the tween if it does, then toggling the boolean.

    I created a tween action which correctly moves onto the screen. However, despite setting the "ping pong" flag to true, the element remains where it tweened to and does not animate back.

    Another attempt I did was to initiate the tween, use a Wait and then try tweening back, but this causes the element to jitter as the two tweens seem to fight for control.

    I've tried using 2 different tweens, 1 in and another out, started when the first completes, but it seems like the first tween doesn't ever complete and fire the event. I also tried adding "destroy on complete" to the tween for testing but the tweening element is never removed.

    Also, looking at the position in the debugger, even though I have the duration of the tween set to 1 second, I can see that the position changes for around 15 seconds, by my manual count, and never actually reaches the specified x value of 64, instead setting around 63.999999999999.

    Tagged:

  • Hard to say based on your description. Maybe the boolean causes the tween to continously trigger instead of triggering it just once? That could explain this behavior.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • WackyToaster is right. A tween should be initiated from a trigger otherwise it will try and start the tween every tick and never finish it.

    If you are using a boolean variable check then add the trigger once condition to the event.

  • Thank you very much calminthenight, that was it! Adding TriggerOnce makes it work properly.

    I thought that changing the boolean value in the action would do the same thing but I guess not.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)