You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

7 years ago
  1. using UnityEngine;
  2. using System.Collections;
  3. using DentedPixel;
  4. public class ExampleSpline : MonoBehaviour {
  5. public Transform[] trans;
  6. LTSpline spline;
  7. private GameObject ltLogo;
  8. private GameObject ltLogo2;
  9. void Start () {
  10. spline = new LTSpline( new Vector3[] {trans[0].position, trans[1].position, trans[2].position, trans[3].position, trans[4].position} );
  11. ltLogo = GameObject.Find("LeanTweenLogo1");
  12. ltLogo2 = GameObject.Find("LeanTweenLogo2");
  13. LeanTween.moveSpline( ltLogo2, spline.pts, 1f).setEase(LeanTweenType.easeInOutQuad).setLoopPingPong().setOrientToPath(true);
  14. LTDescr zoomInPath_LT = LeanTween.moveSpline(ltLogo2, new Vector3[]{Vector3.zero, Vector3.zero, new Vector3(1,1,1), new Vector3(2,1,1), new Vector3(2,1,1)}, 1.5f);
  15. zoomInPath_LT.setUseEstimatedTime(true);
  16. }
  17. private float iter;
  18. void Update () {
  19. // Iterating over path
  20. ltLogo.transform.position = spline.point( iter /*(Time.time*1000)%1000 * 1.0 / 1000.0 */);
  21. iter += Time.deltaTime*0.1f;
  22. if(iter>1.0f)
  23. iter = 0.0f;
  24. }
  25. void OnDrawGizmos(){
  26. if(spline!=null)
  27. spline.gizmoDraw(); // debug aid to be able to see the path in the scene inspector
  28. }
  29. }