Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: falantar on January 24, 2014, 03:03:49 PM

Title: TweenPosition.PlayForward() not animating.
Post by: falantar on January 24, 2014, 03:03:49 PM
I have a tween position script attached to a bar that basically follows the color on the color wheel that you've selected. All it's supposed to do is slide up and down, I got it to work earlier with Mathf.Lerp but I've decided to take the NGUI approach and just change the To and From Vectors when each color is pressed. The bar goes to the right position but it doesn't animate, it's instant. I can't seem to figure out why, the time is set properly and so is the curve. What could be causing this?

Here's the code:

  1.                //Slide the selector bar
  2.                 TweenPosition tp = colorScrollSpy.GetComponent<TweenPosition>();
  3.                 Vector3 tempVec = GameObject.Find(currentColor).gameObject.transform.localPosition;
  4.                 Vector3 currentVec = colorScrollSpy.transform.localPosition;
  5.                
  6.                 tp.from = currentVec;
  7.                 tp.to = new Vector3(currentVec.x, tempVec.y, currentVec.z);
  8.                
  9.                 tp.duration = 0.5f;
  10.  
  11.                 tp.PlayForward();
  12.  
Title: Re: TweenPosition.PlayForward() not animating.
Post by: ArenMook on January 24, 2014, 11:54:51 PM
You should use TweenPosition.Begin to activate tweens via code (doing so also creates a tween if it's not present), and there is no need to set the "from" position. The tween automatically uses the current position as its "from" point.
Title: Re: TweenPosition.PlayForward() not animating.
Post by: falantar on January 27, 2014, 12:41:23 PM
Thanks, that's good to know! Also, fixed my problem. It was my fault, forgot to comment out a line of code I used for debugging.