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 ExtremePowers · Jan 14, 2015 at 04:34 PM · terraintilemissingperlin noiseinfinite

Tile generation problem

I have a problem which isn't there in the editor but whenever I build, it is a problem. The problem is that my terrain generation doesn't generate the middle tile. (It is a 3x3 tile system, which creates a procedurally generated terrain based on the position of the player) The tile isn't there which is a problem because the player can then jump out of the world. I have checked that my tile function is called and that the end of the script is called.

EDIT:

 //terrainSize = 500;
 //terrainHeight = 225;
 function UpdateTile(fromnx : int, fromnz : int, nx : int, nz : int) {
 if (Network.isServer) {
     Seed = PlayerPrefs.GetInt("Seed");
 }
 Random.seed = Seed;
 var Chunk : Terrain;
 
 var ChunkPosX : float = terrainSize * nx;
     var ChunkPosZ : float = terrainSize * nz;
 
     var tmp = GameObject.Find("Chunk "+fromnx+","+fromnz);
     if (tmp) {
         Destroy(tmp);
     }
 var td = new TerrainData();
 td.heightmapResolution = terrainSize/2;
     
 td.size = new Vector3(terrainSize, terrainHeight, terrainSize);
 
 var tmp1 = Terrain.CreateTerrainGameObject(td);
 tmp1.tag = "Chunk";
 Chunk = tmp1.GetComponent(Terrain);
     Chunk = tmp.GetComponent(Terrain);
     var hw : float = Chunk.terrainData.heightmapWidth;

     for (var child : Transform in Chunk.transform) {
             if(child.name == "TreeMaster") {
                     GameObject.Destroy(child.gameObject);
                     Debug.Log("Destroying Treemaster ("+nx+","+nz+")");
             }
     }
     var TreeMaster : GameObject = new GameObject();
     TreeMaster.name = "TreeMaster";
     TreeMaster.transform.parent = Chunk.transform;
     Chunk.transform.position = Vector3(ChunkPosX, 0, ChunkPosZ);
     Chunk.name = "Chunk "+nx+","+nz;
     
     var perlin : PerlinNoise;
     var heightmap = new float[hw,hw];
     for(var x = 0; x < hw; x++) {
         for(var z = 0; z < hw; z++) {
             var worldPosX : float = (x+((hw-1)*(nx-1)))*(terrainSize/hw);
             var worldPosZ : float = (z+((hw-1)*(nz-1)))*(terrainSize/hw);
             if (perlin == null) {
                 perlin = new PerlinNoise(Seed);
             }
             var mountains : float = Mathf.Max(0f, (perlin.FractalNoise2D(worldPosX+250, worldPosZ+250, 7, mountainFrq, 0.5f))-0.1);
             var plain : float = perlin.FractalNoise2D(worldPosX-250, worldPosZ-250, Octaves, groundFrq, 0.5f) + 0.5;
             
             var height = (plain + mountains) * terrainHeight;
             heightmap[z,x] = plain+mountains;
             if (TakeItSlow) {
                 if (z % hw == 0 && x % 2 == 0) {
                     yield null;
                 }
             }
         }
     }
     Chunk.terrainData.SetHeights(0,0,heightmap);
     pf++;
 }
Comment
Add comment · Show 3
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
avatar image ExtremePowers · Jan 14, 2015 at 04:41 PM 0
Share

The seed, is the same through all the tiles, so that isn't the problem.

avatar image Cherno · Jan 14, 2015 at 05:08 PM 0
Share

Post your tile generation script so others can check if anything's wrong with it. Also check the log file of your build if there have been any errors.

avatar image ExtremePowers · Jan 14, 2015 at 05:28 PM 0
Share

There is no errors in the output_log except a shader which is missing, but that shouldn't be the problem.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by khos85 · Jan 14, 2015 at 10:46 PM

Could the tile be there but not in the correct/expected position? Maybe print out coords of tiles to a gui label to check this?

Or: Is your terrain using the missing shader somehow? Fix the shader issue, then test again, Or enclose all code in try catch, check the exception

Comment
Add comment · Show 6 · Share
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
avatar image ExtremePowers · Jan 14, 2015 at 11:19 PM 0
Share

The terrain isn't using the missing shader, it is a shader for some mesh grass I planned on using but never actually made. I will try the thing with the coordinates and return to you with the results :-)

avatar image khos85 · Jan 14, 2015 at 11:50 PM 0
Share

Ok cool , but even if your terrain is not using the shader try to sort that shader error out so you have no errors in game, I suspect that would help. I've seen stuff like that happen in my games.

avatar image ExtremePowers · Jan 15, 2015 at 07:31 AM 0
Share

Okay, so I found out that that wasn't the problem: I printed their position and they are all at the right position. I have also fixed the shader problem but that didn't do anything aswell.

avatar image Cherno · Jan 15, 2015 at 07:44 AM 0
Share

$$anonymous$$aybe the normals of the "missing" tile are flipped and so the tile's mesh only shows from the underside?

avatar image ExtremePowers · Jan 15, 2015 at 07:44 AM 0
Share

I have just tested if the tile is even there, its position gets printed but the tile isn't there at all in the end. I printed the number of tiles in the editor which gave me 9 and when compiled it gave me 8.

Show more comments

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

27 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

Related Questions

Tiling problem with Perlin generated terrain chunks 1 Answer

CoherentNoise still coherent through diferent terrains 0 Answers

How would one approach tile-by-tile terrain generation with Perlin Noise? 0 Answers

Dynamic Terrain Loading 4 Answers

[BEGINNER] Generating Terrain with Perlin noise flat and nothing happens ? 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