public void OnDrag(PointerEventData eventData) { if (slowDownCoroutine != null) { StopCoroutine(slowDownCoroutine); slowDownCoroutine = null; } currentHorizontalRotationVelocity = rotationFactor * eventData.delta.x; OnHorizontalRotation?.Invoke(currentHorizontalRotationVelocity); }
private IEnumerator SlowDown() { float inverseTimer = 1f / slowDownTime; while (timer > 0) { timer -= Time.deltaTime; currentHorizontalRotationVelocity = Mathf.Lerp(slowDownVelocity, 0, 1 - (timer * inverseTimer)); OnHorizontalRotation?.Invoke(currentHorizontalRotationVelocity); yield return(null); } }