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
1
Question by vulgarknight · Jan 25, 2014 at 03:44 AM · terrainloadingworldload asset

Loading terrain files dynamically

I am working on a project involving a large open world. My goal right now is to create a manager that knows which terrain file the player is in, and loads the 8 terrain files around that terrain to place one on each side of the player's current location. The player will be able to roam and not see any terrain updating because the terrains will be larger than the players view distance. I have an idea of the process: create an array of all terrains, determine which terrain the player is on, create another array of all the surrounding terrains plus the current one and load them, unload all terrain files not in the current location array. Actually translating this into c# is a little more difficult. Can anyone point me in the right direction or provide a little bit of insight on this problem?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by getyour411 · Jan 25, 2014 at 03:40 AM

Look at Terrain.SetNeighbors and after changing/setting those, I think it's a good idea to do Terrain.Flush() but that might be myth.

If it helps: http://www.getyour411.com/unoob/terrain1.html

Comment
Add comment · Show 7 · 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 vulgarknight · Jan 25, 2014 at 04:04 AM 0
Share

I have the terrains lined up already. I created the heightmap externally, then divided it into chunks for the individual terrains. I need to load and unload these to follow the player's movement so that I only render the terrains that are close to the player.

avatar image getyour411 · Jan 25, 2014 at 04:34 AM 0
Share

so push your terrain slices into the array of SetNeightbors

avatar image vulgarknight · Jan 25, 2014 at 05:15 AM 0
Share

Ok, so how would the system know where the player is?

avatar image getyour411 · Jan 25, 2014 at 05:30 AM 0
Share

I think you'll have to manage that, you need to know what terrain slice the player is on in order to know what to render/fill into the top/left/right/bottom slices on SetNeighbor. Presumably your GameStart / Load SavedGame would always know what terrain[] you're on.

If I SetNeighbors isn't the answer you were looking for, post back and I'll change to comment so you can get more input.

avatar image vulgarknight · Jan 25, 2014 at 07:51 AM 0
Share

What if I just took the players location and put it up against a set of numbers? Say if the player is at (1110, 132, 2140), then he's between 1000-2000 X (the second tile along the x axis) He is at X=2 for tiles. The character is also between 2000 and 3000 Z, so its the third z tile. The player would then be on top of tile (2,3).

Show more comments
avatar image
0

Answer by paintbox1 · Jan 27, 2014 at 08:29 PM

I know that is not what you want to hear, but it's what stopped me several times, so before you start to worry about the TileManager, you should ask yourself 2 important questions:

1.Are you really able to load a terrain from a file at runtime? Not just the heightmap, but also splatmaps, alphamaps, treeprototypes and positions, detailprototypes and positions... The terrain doesn't provide any built in serialization. You need to deserialize that yourself. And thats just the Terrain. Your game should contain more than terrain, like npcs, buildings and so on. These also need to be loaded. Hint:I ended up, spending months writing different serializers just to find out, Unity blocks the gamecycle for a few seconds, when its setting heights and alphamaps of a terrain. So the player WILL notice, when your terrain is loading.

2.How do you edit your gamecontent? As mentioned in 1. you may want to place GameObjects in your world or even worse: Edit your Terrain. If you load your terrain into the editor and manipulate it. You dont manipulate its neighbors, which leads to different heights/alphas at the edges.

Comment
Add comment · Show 2 · 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 vulgarknight · Jan 27, 2014 at 09:18 PM 0
Share

Well, I make my heightmaps with world machine. I set the tiles by just taking out chunks of the world machine world. I believe most systems would be able to handle JUST the terrain maps and textures, but as you said, I need gameobjects: npc's, items, buildings, lots of other meshes and routines. What do you mean by serialization? Also were you able to work out a dynamic engine to load the terrains in and out? Can it be done in a way that retains the immersion that I'm looking for?

avatar image paintbox1 · Jan 29, 2014 at 08:28 AM 0
Share

By Serialization I mean loading from and saving to files. You dont have 100x100 Terrains in your Assetdatabase, so you just place them in a specific folder and include their index in the filename by some convention. Then you need to be able to reconstruct complete Terrains from those files. And to be able to edit them, you also need your editor to save the terrains to those files you want to load in game.

At the moment I am able to do just what you are looking for, so it is possible, but as I said, loading terrains with ordinary resolutions just blocks your mainthread for seconds, so I have to use heightmaps of 32x32 and alphamaps of 32x32 at terrainsizes of 1000x1000 to keep the freeze times at milliseconds.

avatar image
0

Answer by DaveA · Jan 27, 2014 at 08:32 PM

Look in the Asset Store for such terrain managers

Comment
Add comment · 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

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

21 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

Related Questions

How should you make an MMORPG world? 3 Answers

Tile to Sphere world algorithm 1 Answer

Open World Environment 1 Answer

How can i use Dynamic Terrain Loading? 1 Answer

Seamless Open World Environments 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