Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by PioMine · Sep 06, 2021 at 08:41 PM · map-generation

Map generation by sebastian lague errors

recently i followed the tutorial by sebastian lague and im getting 5 errors that i cant solve:

(51,64): error CS1503: Argument 1: cannot convert from 'float[,]' to 'HeightMap' (55,36): error CS1501: No overload for method 'GenerateTerrainMesh' takes 4 arguments (57,62): error CS1503: Argument 1: cannot convert from 'float[,]' to 'HeightMap' (85,37): error CS1501: No overload for method 'GenerateTerrainMesh' takes 4 arguments (108,29): error CS1501: No overload for method 'GenerateNoiseMap' takes 9 arguments

code:

 using UnityEngine;
 using System.Collections;
 using System;
 using System.Threading;
 using System.Collections.Generic;
 
 public class MapGenerator : MonoBehaviour {
 
     public enum DrawMode {NoiseMap, ColourMap, Mesh, FalloffMap};
     public DrawMode drawMode;
 
     public Noise.NormalizeMode normalizeMode;
 
     public const int mapChunkSize = 241;
     [Range(0,6)]
     public int editorPreviewLOD;
     public float noiseScale;
 
     public int octaves;
     [Range(0,1)]
     public float persistance;
     public float lacunarity;
 
     public int seed;
     public Vector2 offset;
 
     public bool useFalloff;
 
     public float meshHeightMultiplier;
     public AnimationCurve meshHeightCurve;
 
     public bool autoUpdate;
 
     public TerrainType[] regions;
 
     float[,] falloffMap;
 
     Queue<MapThreadInfo<MapData>> mapDataThreadInfoQueue = new Queue<MapThreadInfo<MapData>>();
     Queue<MapThreadInfo<MeshData>> meshDataThreadInfoQueue = new Queue<MapThreadInfo<MeshData>>();
 
     void Awake() {
         falloffMap = FalloffGenerator.GenerateFalloffMap (mapChunkSize);
     }
 
     public void DrawMapInEditor() {
         MapData mapData = GenerateMapData (Vector2.zero);
 
         MapDisplay display = FindObjectOfType<MapDisplay> ();
         if (drawMode == DrawMode.NoiseMap)
         {
             display.DrawTexture (TextureGenerator.TextureFromHeightMap (mapData.heightMap));
         } else if (drawMode == DrawMode.ColourMap) {
             display.DrawTexture (TextureGenerator.TextureFromColourMap (mapData.colourMap, mapChunkSize, mapChunkSize));
         } else if (drawMode == DrawMode.Mesh) {
             display.DrawMesh (MeshGenerator.GenerateTerrainMesh (mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD), TextureGenerator.TextureFromColourMap (mapData.colourMap, mapChunkSize, mapChunkSize));
         } else if (drawMode == DrawMode.FalloffMap) {
             display.DrawTexture(TextureGenerator.TextureFromHeightMap(FalloffGenerator.GenerateFalloffMap(mapChunkSize)));
         }
     }
 
     public void RequestMapData(Vector2 centre, Action<MapData> callback) {
         ThreadStart threadStart = delegate {
             MapDataThread (centre, callback);
         };
 
         new Thread (threadStart).Start ();
     }
 
     void MapDataThread(Vector2 centre, Action<MapData> callback) {
         MapData mapData = GenerateMapData (centre);
         lock (mapDataThreadInfoQueue) {
             mapDataThreadInfoQueue.Enqueue (new MapThreadInfo<MapData> (callback, mapData));
         }
     }
 
     public void RequestMeshData(MapData mapData, int lod, Action<MeshData> callback) {
         ThreadStart threadStart = delegate {
             MeshDataThread (mapData, lod, callback);
         };
 
         new Thread (threadStart).Start ();
     }
 
     void MeshDataThread(MapData mapData, int lod, Action<MeshData> callback) {
         MeshData meshData = MeshGenerator.GenerateTerrainMesh (mapData.heightMap, meshHeightMultiplier, meshHeightCurve, lod);
         lock (meshDataThreadInfoQueue) {
             meshDataThreadInfoQueue.Enqueue (new MapThreadInfo<MeshData> (callback, meshData));
         }
     }
 
     void Update() {
         if (mapDataThreadInfoQueue.Count > 0) {
             for (int i = 0; i < mapDataThreadInfoQueue.Count; i++) {
                 MapThreadInfo<MapData> threadInfo = mapDataThreadInfoQueue.Dequeue ();
                 threadInfo.callback (threadInfo.parameter);
             }
         }
 
         if (meshDataThreadInfoQueue.Count > 0) {
             for (int i = 0; i < meshDataThreadInfoQueue.Count; i++) {
                 MapThreadInfo<MeshData> threadInfo = meshDataThreadInfoQueue.Dequeue ();
                 threadInfo.callback (threadInfo.parameter);
             }
         }
     }
 
     MapData GenerateMapData(Vector2 centre) {
         float[,] noiseMap = Noise.GenerateNoiseMap (mapChunkSize, mapChunkSize, seed, noiseScale, octaves, persistance, lacunarity, centre + offset, normalizeMode);
 
         Color[] colourMap = new Color[mapChunkSize * mapChunkSize];
         for (int y = 0; y < mapChunkSize; y++) {
             for (int x = 0; x < mapChunkSize; x++) {
                 if (useFalloff) {
                     noiseMap [x, y] = Mathf.Clamp01(noiseMap [x, y] - falloffMap [x, y]);
                 }
                 float currentHeight = noiseMap [x, y];
                 for (int i = 0; i < regions.Length; i++) {
                     if (currentHeight >= regions [i].height) {
                         colourMap [y * mapChunkSize + x] = regions [i].colour;
                     } else {
                         break;
                     }
                 }
             }
         }
 
 
         return new MapData (noiseMap, colourMap);
     }
 
     void OnValidate() {
         if (lacunarity < 1) {
             lacunarity = 1;
         }
         if (octaves < 0) {
             octaves = 0;
         }
 
         falloffMap = FalloffGenerator.GenerateFalloffMap (mapChunkSize);
     }
 
     struct MapThreadInfo<T> {
         public readonly Action<T> callback;
         public readonly T parameter;
 
         public MapThreadInfo (Action<T> callback, T parameter)
         {
             this.callback = callback;
             this.parameter = parameter;
         }
 
     }
 
 }
 
 
 

more codes that errors and main code recalls to:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public static class HeightMapGenerator {
 
     public static HeightMap GenerateHeightMap(int width, int height, HeightMapSettings settings, Vector2 sampleCentre) {
         float[,] values = Noise.GenerateNoiseMap (width, height, settings.noiseSettings, sampleCentre);
 
         AnimationCurve heightCurve_threadsafe = new AnimationCurve (settings.heightCurve.keys);
 
         float minValue = float.MaxValue;
         float maxValue = float.MinValue;
 
         for (int i = 0; i < width; i++) {
             for (int j = 0; j < height; j++) {
                 values [i, j] *= heightCurve_threadsafe.Evaluate (values [i, j]) * settings.heightMultiplier;
 
                 if (values [i, j] > maxValue) {
                     maxValue = values [i, j];
                 }
                 if (values [i, j] < minValue) {
                     minValue = values [i, j];
                 }
             }
         }
 
         return new HeightMap (values, minValue, maxValue);
     }
 
 }
 
 public struct HeightMap {
     public readonly float[,] values;
     public readonly float minValue;
     public readonly float maxValue;
 
     public HeightMap (float[,] values, float minValue, float maxValue)
     {
         this.values = values;
         this.minValue = minValue;
         this.maxValue = maxValue;
     }
 }
 
 

and

 using UnityEngine;
 using System.Collections;
 
 public static class TextureGenerator {
 
     public static Texture2D TextureFromColourMap(Color[] colourMap, int width, int height) {
         Texture2D texture = new Texture2D (width, height);
         texture.filterMode = FilterMode.Point;
         texture.wrapMode = TextureWrapMode.Clamp;
         texture.SetPixels (colourMap);
         texture.Apply ();
         return texture;
     }
 
 
     public static Texture2D TextureFromHeightMap(HeightMap heightMap) {
         int width = heightMap.values.GetLength (0);
         int height = heightMap.values.GetLength (1);
 
         Color[] colourMap = new Color[width * height];
         for (int y = 0; y < height; y++) {
             for (int x = 0; x < width; x++) {
                 colourMap [y * width + x] = Color.Lerp (Color.black, Color.white, Mathf.InverseLerp(heightMap.minValue,heightMap.maxValue,heightMap.values [x, y]));
             }
         }
 
         return TextureFromColourMap (colourMap, width, height);
     }
 
     //draw the current ObjectMap
     public static Texture2D TextureFromObjectMap(ObjectMap heightMap) {
         int width = heightMap.values.GetLength (0);
         int height = heightMap.values.GetLength (1);
 
         Color[] colourMap = new Color[width * height];
         for (int y = 0; y < height; y++) {
             for (int x = 0; x < width; x++) {
                 colourMap [y * width + x] = Color.Lerp (Color.black, Color.white, Mathf.InverseLerp(heightMap.minValue,heightMap.maxValue,heightMap.values [x, y]));
             }
         }
 
         return TextureFromColourMap (colourMap, width, height);
     }
 
 }
 

sorry for bothering and thank you in advance

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

124 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to programmatically embed data into 2d terrain through color + heightmap data? 0 Answers

google maps 3d API lacks detail 0 Answers

how do you make a huge 2d texture map made of random picked textures? 2 Answers

Perlin Noise Implementation 2 Answers

How do I make an interactive map on Unity? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges