Hi folks,
I’m currently making a game named “Planetsave” in Unity3D to tell the players that they should save our planet. The game shouldn’t contain environmentally harmful things and planet harmful things. But in one of the scripts, there’s the very shitty unity error CS0103 and I can’t remove this error. It says: “The Name ‘noiseMap’ doesn’t exist in the current content”, but it does exist in the current content! Now I need very urgently help with fixing this very shitty scripting error! Can you please help me? Here’s the C#-source code from the faulty script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TileGeneration : MonoBehaviour {
[SerializeField]
NoiseMapGeneration noiseMapGeneration;
[SerializeField]
private MeshRenderer tileRenderer;
[SerializeField]
private MeshFilter meshFilter;
[SerializeField]
private MeshCollider meshCollider;
[SerializeField]
private float mapScale;
void Start() {
GenerateTile ();
}
void GenerateTile() {
// calculate tile depth and width based on the mesh vertices
Vector3[] meshVertices = this.meshFilter.mesh.vertices;
int tileDepth = (int)Mathf.Sqrt (meshVertices.Length);
int tileWidth = tileDepth;
// calculate the offsets based on the tile position
float[,] heightMap = this.noiseMapGeneration.GenerateNoiseMap (tileDepth, tileWidth, this.mapScale);
// generate a heightMap using noise
Texture2D tileTexture = BuildTexture (heightMap);
this.tileRenderer.material.mainTexture = tileTexture;
}
private Texture2D BuildTexture(float[,] heightMap) {
int tileDepth = noiseMap.GetLength (0);
int tileWidth = noiseMap.GetLength (1);
Color[] colorMap = new Color[tileDepth * tileWidth];
for (int zIndex = 0; zIndex < tileDepth; zIndex++) {
for (int xIndex = 0; xIndex < tileWidth; xIndex++) {
// transform the 2D map index is an Array index
int colorIndex = zIndex * tileWidth+ xIndex;
float height= heightMap[zIndex, xIndex];
// assign as color a shade of grey proportional to the height value
colorMap [colorIndex] = Color.Lerp (Color.black, Color.white, height);
}
}
// create a new texture and set its pixel colors
Texture2D tileTexture = new Texture2D (tileWidth, tileDepth);
tileTexture.wrapMode = TextureWrapMode.Clamp;
tileTexture.SetPixels (colorMap);
tileTexture.Apply ();
return tileTexture;
}
}
And please also note that I’m very new to unity and I only can a bit C#. If you can help me with fixing this very shitty error, it’d be very helpful!
I’ve currently a visitor at home and I’m currently also learning C# from him.
Here I’ve found a resolution, but this shitty resolution doesn’t help me…
Sincerely yours,
Atten007