Author Topic: Reusing tweenPosition?  (Read 6340 times)

derkoi

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 57
    • View Profile
Reusing tweenPosition?
« on: June 08, 2014, 01:35:38 PM »
Hi,

I'm trying to animate a game object from one position to another position in script. I did use TweenPosition.Begin which was fine but I need a smoother animation curve.

I added a tweenPosition component to the game object, adjusted the animation curve to my liking and enabled it via the script. It worked fine once, but when i try to reset the to & from values and re-enable the script it won't allow me to. I can't even enable the script via the check box in the inspector once it's ran once.

I also tried ResetToBeginning() but that didn't make a difference.

Is there something I'm missing please?

Thanks

kittikun

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 46
    • View Profile
Re: Reusing tweenPosition?
« Reply #1 on: June 09, 2014, 03:00:37 AM »
I had exactly the same problem, so I decided to use iTween instead and then everything is working fine.

The only caveat is that you might need to disable anchors or set them to update on enable only

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Reusing tweenPosition?
« Reply #2 on: June 09, 2014, 03:26:19 AM »
ResetToBeginning() will reset the tween to the starting position, which may or may not be what you want. In your case, simply set to 'from' and 'to' values and call the tweener's PlayForward() or PlayReverse() function.