8000 Update mesh collider mesh by ironicnet · Pull Request #1 · z3nth10n/Infinite-Terrain · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update mesh collider mesh #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Assets/Infinite Terrain/Scripts/Core/TerrainGenerator.cs
9A02
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@ private Tile GenerateTile(int x, int z)
// Fix for tiling
float tiling = singlePlaneSize / 20f;

plane.GetComponent<Renderer>().material.SetTextureScale("_MainTex", new Vector2(tiling, tiling));
Renderer renderer = plane.GetComponent<Renderer>();
MeshFilter filter = plane.GetComponent<MeshFilter>();
MeshCollider collider = plane.AddComponent<MeshCollider>();

renderer.material.SetTextureScale("_MainTex", new Vector2(tiling, tiling));

plane.transform.localScale = new Vector3(planeSize * 0.1f, 1, planeSize * 0.1f);
plane.transform.parent = transform;

// Get the planes vertices
Mesh mesh = plane.GetComponent<MeshFilter>().mesh;
Mesh mesh = filter.mesh;
Vector3[] vertices = mesh.vertices;

// alter vertex Y position depending on simplex noise)
Expand All @@ -121,7 +125,8 @@ private Tile GenerateTile(int x, int z)
mesh.RecalculateBounds();
mesh.RecalculateNormals();

plane.AddComponent<MeshCollider>();
collider.sharedMesh = null;
collider.sharedMesh = mesh;

Tile tile = new Tile();
tile.gameObject = plane;
Expand Down
0