1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 17:26:03 +08:00
2015-03-18 19:30:48 +01:00

30 lines
574 B
C#

using DG.Tweening;
using UnityEngine;
using System.Collections;
public class ElasticDragAndRelease : MonoBehaviour
{
public Transform target;
Vector3 orPos;
void Start()
{
orPos = target.position;
}
public void OnClick()
{
StartCoroutine(TweenCoroutine());
}
IEnumerator TweenCoroutine()
{
float range = 2;
Vector3 rnd = new Vector3(Random.Range(-range, range), Random.Range(-range, range), target.position.z);
target.position = orPos + rnd;
yield return new WaitForSeconds(1);
target.DOMove(orPos, 0.6f).SetEase(Ease.OutElastic, 4, 0);
}
}