Example #1
0
    public void CreateVisuals()
    {
        Tracks.GenerateSplitTracks(dockingSpotA.transform.position, dockingSpotB.transform.position, this.transform.position);

        splitToATracks.Clear();
        splitToBTracks.Clear();

        for (int i = 0; i < Tracks.SplitToA.Count; i++)
        {
            GameObject visualGO = Instantiate(trackVisual, Tracks.SplitToA[i], Quaternion.identity, visualParent.transform);
            if (i + 1 < Tracks.SplitToA.Count)
            {
                visualGO.transform.LookAt(Tracks.SplitToA[i + 1]);
            }
            splitToATracks.Add(visualGO);
        }

        for (int i = 0; i < Tracks.SplitToB.Count; i++)
        {
            GameObject visualGO = Instantiate(trackVisual, Tracks.SplitToB[i], Quaternion.identity, visualParent.transform);
            if (i + 1 < Tracks.SplitToB.Count)
            {
                visualGO.transform.LookAt(Tracks.SplitToB[i + 1]);
            }
            splitToBTracks.Add(visualGO);
        }

        for (int i = 0; i < Tracks.OriginToSplit.Count; i++)
        {
            GameObject visualGO = Instantiate(trackVisual, Tracks.OriginToSplit[i], Quaternion.identity, visualParent.transform);
            if (i + 1 < Tracks.OriginToSplit.Count)
            {
                visualGO.transform.LookAt(Tracks.OriginToSplit[i + 1]);
            }
        }
    }