Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by greenSprite_ · Feb 05 at 04:02 AM · topdownprocedural generationminimap

Current strategy for creating my procedural mini map is performance taxing

Basically, I'm procedurally generating a top down game using perlin noise. The actual world is filled out with 16x16 tiles, and my strategy for generating a minimap has been to basically generate the same world but at a smaller scale. The issue with this is that it results with the UI canvas generating thousands of 2x2 pixel sprites and really bogs down the game. Looking for alternative solutions, maybe some way of rendering the map as a single image using the data from world generator?

 public BiomePreset[] biomes;
         public GameObject tilePrefab;
         BiomePreset biomeToReturn;
        
         [Header("Dimensions")]
         public static int width = 50;
         public static int height = 50;
         public static float scale = 1.0f;
         public Vector2 offset;
 
         [Header("Height Map")]
         public Wave[] heightWaves = new Wave[2];
         public float[,] heightMap;
 
         [Header("Moisture Map")]
         public Wave[] moistureWaves = new Wave[1];
         private float[,] moistureMap;
 
         [Header("Heat Map")]
         public Wave[] heatWaves = new Wave[2];
         private float[,] heatMap;
 
         [Header("UI Stuff")]
         public GameObject mapPrefab;
         public GameObject mapBorder;
         public Canvas can;
         public static float scaleFactor = 2;
 
         private void Awake()
         { 
             //rt = mapPanel.GetComponent<RectTransform>();
             GenerateWaves();
             GenerateMap();
         }
         void GenerateMap()
         {
             //height map
             heightMap = NoiseGenerator.Generate(width, height, scale, heatWaves, offset);
             //moisture map
             moistureMap = NoiseGenerator.Generate(width, height, scale, moistureWaves, offset);
             //heat map
             heatMap = NoiseGenerator.Generate(width, height, scale, heatWaves, offset);
             GameObject m = Instantiate(mapBorder, new Vector3(-960 + width, -540 + height, 0), Quaternion.identity);//creates the gameobject which holds the map
             m.transform.SetParent(can.transform, false);//sets the mapholder as a child of the UI canvas
             RectTransform rt = m.GetComponent<RectTransform>();//gets the recttransform of the map holder
             for(int x = 0; x < width; x++)
             {
                 for (int y = 0; y < height; y++)
                 {
                     GameObject tile = Instantiate(tilePrefab, new Vector3(x, y, 2), Quaternion.identity, transform);//generates the tile
                     tile.GetComponent<SpriteRenderer>().sprite = GetBiome(heightMap[x, y], moistureMap[x, y], heatMap[x, y]).GetTileSprite();//sets the tile to the correct sprite
                     tile.GetComponent<TilePrefab>().biome = GetBiome(heightMap[x, y], moistureMap[x, y], heatMap[x, y]);//sets the biome of the tile
                     GameObject dot = Instantiate(mapPrefab, new Vector3((x * 2) , (y * 2), 0), Quaternion.identity, rt); //generates the minimap tile
                     dot.GetComponent<Image>().sprite = GetBiome(heightMap[x, y], moistureMap[x, y], heatMap[x, y]).GetMapSprite(); //sets the minimap tile to correct sprite
                 }
             }
             rt.localScale = new Vector3(scaleFactor, scaleFactor, 1);//scales the map(larger world map will still have same size as smaller world map)
             rt.position = new Vector3(1920 - (width * scaleFactor), 1080 - (height * scaleFactor), 0);//puts the map in the top right corner
         }`

     

Theres more to the script but its not important to the question.

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

179 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 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

TopDown conveyor belt, almost working! 0 Answers

Error Assets/MoveFoward.cs(4,17): error CS8025: Parsing error 1 Answer

Weird infinite loop-or just long loading time 2 Answers

Outline on Texture2D 1 Answer

Procedurally Generated Terrain 1 Answer


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