// Use this for initialization void Start() { float duration = 5; Tween tween = FloatTween.CreateTween(duration, // Called each update with 'time' being time left. (time) => { // (Optional if needed). // To normalize the time value from 0 - 1. // 0 means tween just started, 1 means tween is dead. float normalized = (1.0f - time / duration); // For testing purposes lets move transform somewhere. Vector3 nextPosition = transform.position + Vector3.up * Mathf.Sin(time * time) * Time.deltaTime * 3; // Set the next position. transform.position = nextPosition; }, // Called at the end of the tween. (Tween dies). () => { Debug.Log("Tween has ended!"); }); // Don't forget to start me. tween.Start(); }
void Start() { float duration = 10; float startScale = transform.localScale.x; Vector3 startPosition = transform.position; Tween tween = FloatTween.CreateTween(duration, // Called each update with 'time' being time left. (time) => { // Rotate the transform around startPosition. Vector3 nextPosition = startPosition + Vector3.up * Mathf.Sin(5 * time) + Vector3.left * Mathf.Cos(5 * time); transform.position = nextPosition; }, // Called at the end of the tween. (Tween dies). () => { Debug.Log("Tween has ended!"); }); // Don't forget to start me. tween.Start(); }