Exemplo n.º 1
0
        public static C_PathWaypoint CreateOne(GameObject target, C_Path path, bool isPausePoint = true)
        {
            Debug.Log("生成漫游点");
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            go.transform.SetParent(path.transform);
            go.transform.position = target.transform.position;
            go.transform.rotation = Quaternion.identity;
            go.name = target.name + " path";
            C_PathWaypoint p = go.AddComponent <C_PathWaypoint>();

            p.path     = path;
            p.needStop = isPausePoint;
            return(p);
        }
Exemplo n.º 2
0
        public void CreateOnePoint()
        {
            GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            DestroyImmediate(obj.GetComponent <Collider>());
            obj.transform.SetParent(transform);
            obj.name = "path " + pointS.Count;
            if (pointS.Count > 0)
            {
                obj.transform.position = pointS[pointS.Count - 1].transform.position + new Vector3(1, 0, 1);
            }
            else
            {
                obj.transform.localPosition = Vector3.zero;
            }
            C_PathWaypoint cPoint = obj.AddComponent <C_PathWaypoint>();

            cPoint.path = this;
            pointS.Add(cPoint);
        }
Exemplo n.º 3
0
        /// 生成圆形路径,用来做围绕比较好
        public void CreatCireclePointS()
        {
            anglePre = 360 / pathCount;
            int i = 0;

            for (float angle = 0; angle < 360; angle += anglePre)
            {
                float      x   = transform.position.x + radius * Mathf.Cos(angle * 3.14f / 180f);
                float      y   = transform.position.y + radius * Mathf.Sin(angle * 3.14f / 180f);
                GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                DestroyImmediate(obj.GetComponent <Collider>());
                obj.transform.SetParent(transform);
                obj.name = "path " + i.ToString();
                obj.transform.position = new Vector3(x, transform.position.z, y);
                C_PathWaypoint cPoint = obj.AddComponent <C_PathWaypoint>();
                cPoint.path = this;
                i++;
                pointS.Add(cPoint);
            }
            //draw = true;
        }