IEnumerator UpdateEvenlySpacedPoints() { while (true) { points = curvePath.CalculateEvenlySpacedPoints(movementSpacing, movementResolution); yield return(new WaitForSeconds(0.3f)); } }
public void UpdateRoad() { CurvePath curvePath = GetComponent <PathCreator>().curvePath; Vector2[] points = curvePath.CalculateEvenlySpacedPoints(spacing); GetComponent <MeshFilter>().mesh = CreateRoadMesh(points, curvePath.IsClosed); int textureRepeat = Mathf.RoundToInt(tiling * points.Length * spacing * 0.05f); GetComponent <MeshRenderer>().sharedMaterial.mainTextureScale = new Vector2(1, textureRepeat); }
// Use this for initialization void Start() { curvePath = FindObjectOfType <PathCreator>().curvePath; points = curvePath.CalculateEvenlySpacedPoints(movementSpacing, movementResolution); //foreach (Vector2 p in points) //{ // GameObject.Instantiate(roadLight, new Vector3(p.x, p.y, -1.0f), Quaternion.identity); //} StartCoroutine(UpdateEvenlySpacedPoints()); }
public void UpdateRoad() { if (roadQuadsList.Count > 0) { for (int i = roadQuadsList.Count - 1; i >= 0; i--) { Destroy(roadQuadsList[i].gameObject); } } CurvePath curvePath = GetComponent <PathCreator>().curvePath; Vector2[] points = curvePath.CalculateEvenlySpacedPoints(spacing); for (int i = 1; i < points.Length; i++) { g = Instantiate(roadQuadPrefab, points[i], Quaternion.identity) as GameObject; g.transform.localScale = quadScale; roadQuadsList.Add(g); //g.transform.rotation = Quaternion.LookRotation( Vector3.forward, new Vector3(points[i-1].x,points[i-1].y,0)); } }