Author Topic: Chain Pingpong Tween Position  (Read 3289 times)

singh029

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 28
    • View Profile
Chain Pingpong Tween Position
« 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.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Chain Pingpong Tween Position
« Reply #1 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.