Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: singh029 on June 02, 2014, 05:24:03 AM

Title: Chain Pingpong Tween Position
Post by: singh029 on June 02, 2014, 05:24:03 AM
Could you suggest a way to pingpong 2 sprites using OnFinished or when the sprite equals a certain position.
I want to have the second sprite start after the first one gets back to its initial (from) position.
The logic is wrong. Since Pingpong is endless, how do i check if it reached its initial position again so i can start the second sprite?

  1.        
  2. void Update()
  3. {
  4.      if (leftPosTween.to.sqrMagnitude >  new Vector3(0,70,0).sqrMagnitude)
  5.      {
  6.             rightPosTween.enabled = true; // set to false in Start()
  7.             rightPosTween.Play();
  8.      }
  9. }
  10.  
  11.  
Title: Re: Chain Pingpong Tween Position
Post by: ArenMook on June 02, 2014, 11:08:33 PM
Don't use PingPong for that. Instead use linear interpolation, and change the curve to go from A at 0, to B at 0.5, then back to A at 1.0.