예제 #1
0
 public void DestroyPath()
 {
     if (this.currentPath != null)
     {
         GameObject.DestroyImmediate(this.currentPath.gameObject);
         this.currentPath = null;
     }
 }
예제 #2
0
        public void MovePath(List <Vector3> points, bool loop = false)
        {
            if (this.currentPath != null)
            {
                GameObject.DestroyImmediate(this.currentPath.gameObject);
                this.currentPath = null;
            }

            this.currentPath      = this.GeneratePathManager(this.gameObject.name, points);
            this.mover.moveToPath = true;
            this.mover.loopType   = loop ? SWS.splineMove.LoopType.pingPong : SWS.splineMove.LoopType.none;
            this.mover.SetPath(this.currentPath);
        }
예제 #3
0
        private SWS.PathManager GeneratePathManager(string name, List <Vector3> points)
        {
            GameObject obj = new GameObject();

            obj.name = name + "Path";

            SWS.PathManager path = obj.AddComponent <SWS.PathManager>();
            path.waypoints = new Transform[points.Count];

            for (int i = 0; i < points.Count; i++)
            {
                GameObject nodeObj = new GameObject("node" + i);
                nodeObj.transform.position = points[i];

                nodeObj.transform.SetParent(obj.transform);
                path.waypoints[i] = nodeObj.transform;
            }

            return(path);
        }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     this.mover       = this.gameObject.GetComponent <SWS.splineMove>();
     this.pathManager = this.gameObject.GetComponent <SWS.PathManager>();
     this.controller  = this.gameObject.GetComponent <SplineController>();
 }