basaranb
2/11/2019 - 11:37 AM

DO Tween Create Path from Objects and Follow Path

Vector3[] path; 

public List<GameObject> obstacles = new List<GameObject>(); 

path = new Vector3[obstacles.Count]; //initialize path array 

for (int i = 0; i<obstacles.Count; i ++) 
        { 
            Debug.Log(obstacles[i].transform.position); 
            path[i] = obstacles[i].transform.position; 
        } 

transform.GetComponent<Rigidbody>().DOPath(PATH, 30f,PathType.CatmullRom, PathMode.Sidescroller2D).SetLookAt(0.01f).SetLoops(-1, LoopType.Yoyo); 

//SetLookAt(0.01f)   look in front along the path 
//SetLoops(-1, ...) infinite loop
//SetEase(Ease.Linear)   set Ease type