*

cem

  • *
  • 5
    • View Profile
Tweening with a moving endPosition
« on: January 18, 2016, 06:30:27 PM »
I have a moving platform where I want to tween my object to. From what i understood it's not possible; so the end position must be 'static' . Can someone confirm ?
Thanks !

Re: Tweening with a moving endPosition
« Reply #1 on: February 17, 2016, 10:19:16 PM »
You can add an OnUpdate to the tween like this:
Code: [Select]
Tweener tweener = target.DOMove(followTarget.position, speed).SetSpeedBased(true);
tweener.OnUpdate(delegate () {
        // if the tween isn't close enough to the target, set the end position to the target again
        if(Vector3.Distance(target.position, followTarget.position) > completionRadius) {
    tweener.ChangeEndValue(followTarget.position, true);
}
});