Пример #1
0
    void GenerateTrack()
    {
        LevelData LD = FindObjectOfType <LevelData>();

        if (LD)
        {
            TrackData d = LD.d;

            DestroyImmediate(LD.gameObject);

            NM.clearNM();
            TG.LoopTrack = d.loop;

            for (int i = 0; i < d.rotations.Length; i++)
            {
                Vector3 pos = new Vector3(d.positions[i * 3], d.positions[(i * 3) + 1], d.positions[(i * 3) + 2]);
                NM.AddNewNode(pos, false, d.rotations[i], false);

                GameObject box = new GameObject();
                box.transform.parent   = transform;
                box.transform.position = pos;
                box.transform.rotation = Quaternion.Euler(0, d.rotations[i], 0);

                BoxCollider b = box.AddComponent <BoxCollider>();

                b.size      = new Vector3(10, 10, 1);
                b.isTrigger = true;

                Tracker.Add(b);

                box.AddComponent <LapTriggers>().ID = i;
            }

            maxID = d.rotations.Length;

            TG.GenerateAllSegments();
        }
    }