PathBezier2d.cs 906 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PathBezier2d : MonoBehaviour {
  5. public Transform[] cubes;
  6. public GameObject dude1;
  7. public GameObject dude2;
  8. private LTBezierPath visualizePath;
  9. void Start () {
  10. // move
  11. Vector3[] path = new Vector3[]{cubes[0].position,cubes[1].position,cubes[2].position,cubes[3].position};
  12. // 90 degree test
  13. // path = new Vector3[] {new Vector3(7.5f, 0f, 0f), new Vector3(0f, 0f, 2.5f), new Vector3(2.5f, 0f, 0f), new Vector3(0f, 0f, 7.5f)};
  14. visualizePath = new LTBezierPath(path);
  15. LeanTween.move(dude1, path, 10f).setOrientToPath2d(true);
  16. // move local
  17. LeanTween.moveLocal(dude2, path, 10f).setOrientToPath2d(true);
  18. }
  19. void OnDrawGizmos(){
  20. // Debug.Log("drwaing");
  21. Gizmos.color = Color.red;
  22. if(visualizePath!=null)
  23. visualizePath.gizmoDraw(); // To Visualize the path, use this method
  24. }
  25. }