PathSpline2d.cs 737 B

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. using System.Collections;
  3. using DentedPixel;
  4. public class PathSpline2d : MonoBehaviour {
  5. public Transform[] cubes;
  6. public GameObject dude1;
  7. public GameObject dude2;
  8. private LTSpline visualizePath;
  9. void Start () {
  10. Vector3[] path = new Vector3[] {
  11. cubes[0].position,
  12. cubes[1].position,
  13. cubes[2].position,
  14. cubes[3].position,
  15. cubes[4].position
  16. };
  17. visualizePath = new LTSpline( path );
  18. // move
  19. LeanTween.moveSpline(dude1, path, 10f).setOrientToPath2d(true).setSpeed(2f);
  20. // move Local
  21. LeanTween.moveSplineLocal(dude2, path, 10f).setOrientToPath2d(true).setSpeed(2f);
  22. }
  23. void OnDrawGizmos(){
  24. Gizmos.color = Color.red;
  25. if(visualizePath!=null)
  26. visualizePath.gizmoDraw();
  27. }
  28. }