Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class LerpCycle : MonoBehaviour {
- public Transform start;
- public Transform end;
- public float frequency;
- // Use this for initialization
- IEnumerator Start () {
- float startTime = Time.time;
- while (true)
- {
- float cycle = Mathf.Sin(frequency * Time.time); // -1 to 1
- cycle += 1; // 0 to 2
- cycle /= 2; // 0 to 1
- transform.position = Vector3.Lerp(start.position, end.position, cycle);
- yield return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment