Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: cem on January 18, 2016, 06:30:27 PM

Title: Tweening with a moving endPosition
Post by: cem 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 !
Title: Re: Tweening with a moving endPosition
Post by: jffshck 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);
}
});