Good day, i try to make an level generator in Unity. But i had a error in my my code bzw. the mesh generator code for error and code see down bellow, i am dont know how to fix the problem. Thanks in Advance. Code (CSharp): //meshGenarator.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public static class meshGenerator { public static void GenerateTerraiMesh(float[,] heigthMap) { int width = heigthMap.GetLength(0); int heigth = heigthMap.GetLength(1); float topLeftX = (width - 1) / -2f; float topLeftZ = (heigth - 1) / 2; MeshData meshData = new MeshData(width, heigth); int vertexIndex = 0; for (int y = 0; y < heigth; y++) { for (int x = 0; x < width; x++) { meshData.vertecies[vertexIndex] = new Vector3(topLeftX + x, heigthMap[x, y], topLeftZ - y); meshData.uvs[vertexIndex] = new Vector2(x / (float)width, y / (float)heigth); if (x < width -1 && y < heigth - 1) { meshData.AddTriangle(vertexIndex, vertexIndex + width + 1, vertexIndex + width); meshData.AddTriangle(vertexIndex + width + 1, vertexIndex + 1); } vertexIndex++; } } return meshData; } } public class MeshData { public Vector3[] vertecies; public int[] triangles; public Vector2[] uvs; int triangleIndex; public MeshData(int meshWidth, int meshHeigth) { vertecies = new Vector3[meshWidth * meshHeigth]; uvs = new Vector2[meshWidth * meshHeigth]; triangles = new int[(meshWidth - 1) * (meshHeigth - 1) * 6]; } public void AddTriangle(int a, int b, int c) { triangles[triangleIndex] = a; triangles[triangleIndex + 1] = b; triangles[triangleIndex + 2] = c; triangleIndex += 3; } public Mesh CreateMesh() { Mesh mesh = new Mesh(); mesh.vertices = vertecies; mesh.triangles = triangles; mesh.uv = uvs; mesh.RecalculateNormals(); return mesh; } } // // errors //Schweregrad Code Beschreibung Projekt Datei //Zeile Unterdrückungszustand //Fehler CS7036 Es wurde kein Argument angegeben, das dem //formalen Parameter "c" von "MeshData.AddTriangle(int, int, //int)" entspricht. //Schweregrad Code Beschreibung Projekt Datei //Zeile Unterdrückungszustand //Fehler CS0127 Da //"meshGenerator.GenerateTerraiMesh(float[*,*])" "void" //zurückgibt, darf auf ein Rückgabeschlüsselwort kein //Objektausdruck folgen.
An ERROR! My goodness... and even worse... a ... Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind. The important parts of an error message are: - the description of the error itself (google this; you are NEVER the first one!) - the file it occurred in (critical!) - the line number and character position (the two numbers in parentheses) All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum. How to understand compiler and other errors and even fix them yourself: https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855 How to report your problem productively in the Unity3D forums: http://plbm.com/?p=220
The first error seems to say that you're missing variable "c" in a line where you call AddTriangle. The error stems from line 29, where you're only assigning 2 variables. On line 28 you're assigning 3 properly. I don't quite understand the second error, I'm sorry. Might I also add that you have a typo in "GenerateTerraiMesh" because the "n" in "Terrain" is missing.