Author Topic: Resetting Tweens  (Read 17351 times)

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Resetting Tweens
« on: September 21, 2012, 07:08:34 PM »
Hi,

I'm using the TweenColor script to make a flashing color effect that is using the ping pong preset to go back and forth between 2 colors. I am wondering if there is a convenience method or if one could be added that would allow the object that is being tweened to be reset to it's original color/position,etc..?

Usually I find that I am enabling and disabling these tweens as they are needed but then the object they are on just stays on the last state it was on (ie: the color in between the from and to colors), and the Reset function doesn't actually modify the object. It would be great if there was a "resetObject" method or something that put the object back into the state it was in before the tween was activated.

-JJ

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resetting Tweens
« Reply #1 on: September 21, 2012, 10:56:55 PM »
You can call tween.Sample(tween.tweenFactor, false) after your Reset() call to achieve what you want.

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Re: Resetting Tweens
« Reply #2 on: December 14, 2013, 05:26:08 PM »
Sorry to resurrect this old thread, but I have a similar problem as capitalj. Maybe somebody has some ideas why this is happening.

I am using a TweenPosition which moves my objects position a bit to achieve some 'jiggling. effect. When I stop the tween however it just stops at the last position it was in, not the original position of the object it would have without the tween active.

  1. myObj.GetComponent<TweenPosition>().Reset();
  2. myObj.GetComponent<TweenPosition>().enabled = false;

This should reset the tween to the beginning and then disable it, or not? For me, after disabling the tween, it somehow leaves my sprite in the last position from somewhere within the tween instead of the original position.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resetting Tweens
« Reply #3 on: December 14, 2013, 07:19:11 PM »
Reset() is a Unity function. It's also private in the last version in order to avoid confusion. If you want the tween to play from the beginning call its PlayForward() function.

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Re: Resetting Tweens
« Reply #4 on: December 16, 2013, 11:59:48 AM »
I think that still cancels the current tween where ever it is at the moment and might cause some odd visuals. Ideally I would want the tween to run through to the end and then stop to avoid popping/jumping. However, in my case its rather simple and its not really noticeable. So, PlayForward() did the job. Thanks!

GameMasons

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Resetting Tweens
« Reply #5 on: December 26, 2013, 08:09:27 PM »
This does not seem to work with a ping pong rotation. If the object is on the backside of the transition, the Pong if you will, the reset only takes to back to the end point of ping.

Example:

Object activated to go to 0,0,90 and then ping pong back to 0,0,0,
If you deactivate the tween on the way back from 0,0,90, when you reactivate the the tween, the object starts its rotation from 0,0,90.

How do you get it to always start from 0,0,0.

I have tried - Reset(), PlayForward, etc.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resetting Tweens
« Reply #6 on: December 26, 2013, 09:03:46 PM »
To create a ping-pong rotation, consider simply changing the curve to be shaped like an upside-down "U", so that the begin and end points are the same.

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: Resetting Tweens
« Reply #7 on: December 27, 2013, 10:46:19 AM »
there's a ResetToBegining() function which does what Reset() used to do, might help