public IEnumerator GenerateNextPoint()
    {
        //generationX =
        while (true)
        {
            // Delete any Points behind the player
            //for (int i = 0; i < curvePath.NumSegments/2; i++)
            //{
            //	if (player.transform.position.x > curvePath.GetPointsInSegment(i)[3].x)
            //	{
            //		curvePath.DeleteSegment(i);
            //	}
            //}
//

            generationX += forwardDistanceBetweenPoints;
            float generationY = Random.Range(-curviness, curviness);


            Instantiate(roadLight, new Vector3(generationX, generationY, roadLightHeight), Quaternion.identity);

            // Add new Point
            curvePath.AddSegment(new Vector2(generationX, generationY));



            quadRoadCreator.UpdateRoad();



            yield return(new WaitForSeconds(timeBetweenPointGeneration));
        }
    }
    public IEnumerator GenerateNextPoint()
    {
        while (true)
        {
            //Debug.Log("Generate Point!");


            generationX += forwardDistanceBetweenPoints;
            float generationY = Random.Range(-curviness, curviness);


            Instantiate(roadLight, new Vector3(generationX, generationY, roadLightHeight), Quaternion.identity);

            // Add new Point
            curvePath.AddSegment(new Vector2(generationX, generationY));

            // Remove Oldest Point Every
            if (Mathf.FloorToInt(Time.time) % Mathf.FloorToInt(6 * timeBetweenPointGeneration) == 0)
            {
                //curvePath.DeleteSegment(0);
            }


            roadCreator.UpdateRoad();


            yield return(new WaitForSeconds(timeBetweenPointGeneration));
        }
    }
Beispiel #3
0
    private void Input()
    {
        Event   guiEvent = Event.current;
        Vector2 mousePos = HandleUtility.GUIPointToWorldRay(guiEvent.mousePosition).origin;

        if (guiEvent.type == EventType.MouseDown && guiEvent.button == 0 && guiEvent.shift)
        {
            Undo.RecordObject(creator, "Add segment");
            _curvePath.AddSegment(mousePos);
        }
    }