//changes the terrain at the location of a collider public void changeTerrain() { resetTerrain(); GameObject [] hillWidgets; hillWidgets = GameObject.FindGameObjectsWithTag("hillWidgetContainer"); foreach (GameObject hillWidget in hillWidgets) { HillWidget current = hillWidget.GetComponent <HillWidget>(); current.SetWidth(); float xPos = current.GetPosition().x; float zPos = current.GetPosition().z; float yPos = current.GetPosition().y; float width = current.GetWidth(); CreateHill(xPos, zPos, yPos, width, current.getOffset(), current.getSteepness()); if (current.getPair() != null) { if (current.GetPoints() != null) { for (int i = 0; i < current.GetPoints().Count; i++) { current.ChangePoint(); CreateRidge(current.GetPoints()[i].x, current.GetPoints()[i].z, (current.GetPosition().y *(1 - ((float)i / current.GetPoints().Count)) + current.getPair().GetPosition().y *(((float)i / current.GetPoints().Count))), width, i); } } } } foreach (GameObject hillWidget in hillWidgets) { HillWidget current = hillWidget.GetComponent <HillWidget>(); if (!current.GetComponentsInChildren <OVRGrabbable>()[0].isGrabbed && !current.GetComponentsInChildren <OVRGrabbable>()[1].isGrabbed) { current.SetPosition(false); } current.setHeight(heights[(int)(((current.GetPosition().z / scale) + 1) * 256 + current.getOffset().y), (int)(((current.GetPosition().x / scale) + 1) * 256 + current.getOffset().x)] * scale * 2);//sets the height of constraints to, at minimum, the terrain height /*if (current.getPair() != null) * { * if (current.GetPoints() != null) * { * for (int i = 0; i < current.GetPoints().Count; i++) * { * //current.ChangePoint(heights[(int)(((current.GetPoints()[i].z/scale) + 1) * 256), (int)(((current.GetPoints()[i].x /scale) + 1) * 256)]*scale*2, i); * } * } * }*/ current.DrawLine(); } terr.terrainData.SetHeightsDelayLOD(0, 0, heights); }
public void addPair(HillWidget other) { widgetPair = other; }