1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-21 01:36:05 +08:00
Demigiant f3a549436b Hyper-compatible version fix which allows Color32 to work correctly
+ Fix to ScrollRect.DONormalizedPos not working correctly with hyper-compatible mode
2016-03-12 15:42:09 +01:00

25 lines
794 B
C#

using UnityEngine;
using System.Collections;
using DG.Tweening;
public class FollowTargetUntilReached : MonoBehaviour
{
public Transform targetToFollow;
public Transform follower;
void Start()
{
// Create tween and use OnUpdate to follow that target.
// In this case, when the target is reached the tween will be
// automatically killed and the following will stop
Vector3 prevTargetPos = targetToFollow.position;
Tweener followTween = follower.DOMove(targetToFollow.position, 4);
followTween.OnUpdate(()=> {
if (prevTargetPos != targetToFollow.position) {
prevTargetPos = targetToFollow.position;
followTween.ChangeEndValue(targetToFollow.position, 2, true).Restart();
}
});
followTween.OnComplete(()=> Debug.Log("Target reached and tween killed"));
}
}