using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; public class EventWashingGestureFollow : MonoBehaviour { [SerializeField] public float displayTime = 0f; private float remainingTime; public void SetFollowPosition(Vector3 position, float speed) { float distance = Vector3.Distance(this.gameObject.transform.position, position); float time = distance / speed; this.gameObject.transform.DOKill(); this.gameObject.transform.DOMove(position, time).SetEase(Ease.Linear); remainingTime = displayTime; if (this.gameObject.activeSelf == false) this.gameObject.SetActive(true); } // Update is called once per frame void Update() { if (remainingTime > 0) { remainingTime -= Time.deltaTime; if (remainingTime <= 0f) { this.gameObject.SetActive(false); } } } }