Using .yoyo in tweening

Hello guys, i want to create event where .yoyo will be used.

I want to move something through tween position , but yoyo it back when the event is triggered.

Any ideas?

image

Sorry, but what is the question?

To use yoyo, simply pass true/false to it. Please, refer to the guide:
https://developer.playcanvas.com/en/tutorials/tweening/

I simply want my object to yoyo when the button is pressed,and only once, not by checkboxing it in editor.

It sounds like you want to use .yoyo without the yoyo. If that’s the case you maybe can use two tweens in the opposite direction?

1 Like

Call the tween with yoyo and loop disabled when the button is clicked.

2 Likes

Adding to @yaustar’s advice,

Make sure when you disable loop that you set repeat() to 2. Here is the link to the relevant doumentation:

1 Like

Thanks for advice, although i want it to tween the object back when the button is clicked again, and if clicked again, tween it to target position and so on…

Sounds like you just need two tweens as was mentioned above. One to get there on the first click, and another when it is clicked again

I just solved it a little differently, i used this:

Created event for both tweeningTo and tweeningBack, and fired them when button clicked, i have also condition for clicking whether it should tweenTo or tweenBack.