Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Runtime Terrain Editing [WIP]

Discussion in 'Works In Progress - Archive' started by judah4, Sep 23, 2013.

  1. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    I search around for a way to save, load, and edit terrains on runtime but I couldn't find anything that could do what I want so I started creating my own.

    $terrainEditv1.png
    $Tree brush.PNG
    All made in game

    Web Player
    Windows Download With saving

    I had to disable the loading and saving in the webplayer because of how it cannot write files on the computer.

    So far, I can tile terrains, edit heights of the terrain and neighboring tiles, add and remove trees, change terrain textures, and save and load the terrains all while playing. The total world size I set to 36 km x 36 km but it only loads about 1.2 km^2 at a time. Each terrain piece is 500 units which I hope can help with performance. Eventually, I want this to be nice system that lets me edit terrain like in the editor ingame without dropping the frame rate to much.

    fly around with right mouse click and WASD.
    click on the terrain to edit. Shift and click removes trees or lowers the terrain
    When editing objects, numbers 1,2,3 allow position, rotation, scale changes. When an object is selected, click attach objects in the properties panel.

    Features
    Edit the terrain all in game
    Adjust terrain height with a brush, set it to a certain height or smooth it out,
    Tile terrains for large worlds
    Saving pieces to be loaded later when needed
    Add trees and grasses
    stitch terrain edges together with no gaps
    Object Placement System and terrain anchoring
    World Wrapping from west and east.
    Undos for height changes
    Planned things to add-
    Making edges blend together better
    faster loading
     
    Last edited: Nov 11, 2013
    SniperEvan, p890040, Origxn and 2 others like this.
  2. GoodEnoughGames

    GoodEnoughGames

    Joined:
    Jun 2, 2013
    Posts:
    66
    Damn that's good. Feels smoother than the actual unity editor :p
     
    Gekigengar likes this.
  3. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Really impressive. Great job. Will follow.
     
  4. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    Thank you. I added a way to smooth terrain and flatten terrain and updated the webplayer to show this. I also worked on aligning the seems on the terrain and it mostly works for the height brush except corners are a tough challenge so far.
     
  5. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    I updated the webplayer with a new build.
    $Little oasis.PNG

    I was able to stitch edges crudely but it works for now. You can add grass, smooth, flatten, and change the height without creating holes in the terrain though I haven't set it error proof when editing a terrain with an adjacent chunk not loaded.
     
  6. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    I'm making progress on the ingame terrain editor. Loading and saving terrains is multithreaded but the framerate still dips on my laptop. I raised the terrain pieces from 256 to 512 units since all the terrain culling slowed stuff down to much from what I saw in the profiler. I'm going to try to update the webplayer later today and make a stand-alone build to show the loading and saving stuff. Stitching terrains together works pretty well but it is just simple for now and does not take the differences between the edges yet. The smooth brush works but does not have the same functionality as the editor smooth brush which I was trying to emulate so I will have to go back and fix that eventually.

    I'm hoping to make an object placement system that will load object with the terrains and anchor them in a certain position so that you can edit still and have what ever you placed stay on the surface.
    Eventually I want to be able to sell this on the asset store so I'm trying to make this as nice and versatile as possible.
     
  7. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    $Object Editing.png
    I updated the webplayer with a few things. Now you start in first person mode where you can start editing directly or go into fly mode and start editing. I began working on an object placement system which so far has not given me to much trouble and I was able to anchor the objects to the terrain so they didnt disappear when changing the terrain height.
     
  8. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    Okay, updated the webplayer and added a lot more features.

    $Tree brush.PNG
    I finally got a tree brush working and it makes sure there are not so many trees within 1 meter of each other. memory usage explodes when you use the max size brush so I'm going to have to find a way to prevent that soon.

    I was able to have a simple undo system that stores the previous height of the terrain and then lets you undo what changed the last time the mouse button was pressed. Next will be to revert textures back.

    Objects can be attached to the terrain or to other objects. This allows you to place a building and then be able to attach furniture inside and then be able to move the building without have to rearrange everything inside each time.

    Terrain files where getting way to large at about 2,660 kb per 500 m square so I added file compression as I save the files making them about 10 to 40 kb each instead.

    To get a feel of what it does with the saving and loading, try the download here. It is the actual tool I'm using to make my own game. and it saves me a lot of time with making sure the terrain seems match up. https://drive.google.com/file/d/0B2Xzw5uBbDL8UlYwN1RsR1pJTFk/edit?usp=sharing

    I'm still having some hiccups with slower systems when loading a terrain chunk but I'm improving it.

    If anyone is interested, I'm hoping to put this in the unity store. Please reply if this is something you would like to see.
     
  9. wmaass88

    wmaass88

    Joined:
    Dec 23, 2012
    Posts:
    45
    I am very interested in this should you put it in the Asset Store. Good work!
     
  10. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    good to hear. Now to think of a proper name for it. I think im going to start making some documentation this week
     
  11. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    461
    This is good.

    Yes, re asset store.
     
  12. uy

    uy

    Joined:
    Jun 18, 2013
    Posts:
    55
    I really like the whole user workability and idea! The only thing is with the camera moving. I feel really constrained with it. I have a script I made where the camera movement is basically the exact same as in the unity editor... would you be interested in that? If not (and I understand why), then I think you should change the camera movement to make it easier for the user.
     
  13. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    I tried making it like the unity camera, but it can collide with objects and drifts a little to much. I would be interested in a camera that acts a little more like the editor.
     
  14. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    This is awesome judah4!!

    whats your plans with this?

    are you going to sell it on the asset store?

    if yes then do you have an eta?

    if yes then how much £££?
     
  15. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    I was planning on using it for my game(which is going well) and sell it on the asset store. I was thinking about $20 dollars because while it does a lot, I want to keep the cost down for us poor indies :p Timewise, I still need to make sure I have some more proper documentation and the asset picture. Heres what I have for documentation so far Realtime editing Doc.

    I recently added custom properties to save for the objects placed like which creature to spawn at the position or something like that. My largest bottleneck is writing all the heightmap data to the terrain. Im going to have to experiment how much I can write on another thread without creating to much garbage for the GC.

    I'll see what I can do about releasing it soon. I have spring break next week so I will have free time to get everything together.
     
  16. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Amazing work, this sounds like an ideal tool for me. Is the chunk system like "Terrain Slicing Neighboring Kit" which enables you to load/save chunks seamlessly as you move?

    Please do continue your project!
     
  17. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    That is the plan and that is what I have at the moment. Each tile is 500 units wide so it loads up about 3 of them in all the directions around the camera. If the camera moves, it loads up new tiles or removes old ones when the are to far away. Im also trying to get world shifting working so that everything stays close to the 0,0 point of the world to keep all the floating point precision. So far, my shifting idea works on a simple testing scene but I need to further test it and then integrate it to the world builder.
     
  18. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    514
    Just wanted to say that i've already done this in my application i'm building called Virtuoso Life using Unity. I hope this project your doing finds the unity asset store well worth the effort.

     
  19. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    461
    I like this.

    I'll buy this for $20 when it's released.
     
  20. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    This asset is worth much more IMO, can't complain though :p Whatever the final price, I would get it once it's released. Keep up the good work
     
  21. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    @judah4: as I said in the PN few weeks ago you have created a very good tool similar to what I need in my next game. You made a good job on this one! :)

    However, since this terrain editor is still not in the Asset Store I had to create my own solution. Now is the question should I upload it to the Asset Store, do you dev guys need it? If yes please tell me here if there is nobody interested then I don't need to make any documentation and will have to keep my multiplatform runtime level editor for my self o_O
     
  22. phupang

    phupang

    Joined:
    Nov 1, 2012
    Posts:
    6
    Yes, I want to buy
     
  23. knr_

    knr_

    Joined:
    Nov 17, 2012
    Posts:
    258
    It does feel smooth - probably because it doesn't have the Editor overhead ;)

    Looks great, keep going!
     
  24. sanuvin

    sanuvin

    Joined:
    Feb 11, 2014
    Posts:
    61
    would buy
     
  25. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    So, Unity5 broke the projector shader I was using so I'm fixing that up. I'm also looking to clean up how prefabs are placed and stored so that it uses the resources folder instead of a big list.
     
  26. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    God, this is much smoother than the editor version.
    The smoothing actually works, the mouse point to brush raycasting is far more accurate than Unity's.

    Makes me realize how abandoned is our current terrain editor.
     
  27. Gf15a4

    Gf15a4

    Joined:
    May 11, 2014
    Posts:
    6
    Can you help me out on my own adventures if you will. I am making the same thing as you for a city builder and get 50fps for a brush size that has the radius of 50 or diameter of 100. I have unlimited terrain by using chunks the size of 100. If the chunk is in range i iterate through every vertice casting a distance and using that for rasing or lowering. I want to raise my max brush radius to 300 or 400 but performance wont let me haha. I can use a 100 radius or 200 diameter with fps of about 15 but I really hope I can do better.
     
  28. p890040

    p890040

    Joined:
    Apr 27, 2015
    Posts:
    1
    It let me feel impressive and excited.
    I have send a message, a few questions to you. I hope you can response to me. Thanks !
     
  29. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    143
    Very interesting and promising product!
    Is there the chance to try a demo? or could you tell us when you will publish it?
     
  30. GalacticGlum

    GalacticGlum

    Joined:
    Jul 30, 2015
    Posts:
    31
    This is really nice!

    I'm creating a 3D First Person Survival Role Playing game, and I WILL be using this when it is released!
    I've been looking around for a in game map editor and this is perfect, since the main map is the same each time (it's pretty big though, and you spawn in a different place each time). I'm going to add in a map creater/editor option in the main menu for people to make their own maps and play them, which will also allow for servers to have custom maps.

    Thanks so much!
     
    Last edited: Aug 2, 2015
  31. SniperEvan

    SniperEvan

    Joined:
    Mar 3, 2013
    Posts:
    161
    Did this evet make it to the store?
     
  32. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    No, I never got this out. After using the system internally for a while, I've decided it needs a whole rewrite. With the way the terrain is loaded, using 3rd party terrain addons like RTP is difficult, and placing objects in the editor takes extra work.

    Pretty much, I'm not sure where to take this yet and needs much more work to be game ready. Internally, I switched back to loading scenes with terrain through LoadLevelAdditiveAsync but I have not worked out runtime/player object loading and there is a little stutter when loading an additive scene. Current ETA on letting other people use it is to be determined but probably a long ways away.
     
  33. sofschmi

    sofschmi

    Joined:
    Sep 7, 2018
    Posts:
    2
    This is amazing! Is there any way I can get a hold on the source code or maybe receive some guidelines on how to obtain similar results? I have searched for ways to implement Terrain Editing in Runtime in Unity, but sadly I have not yet found viable sources.
    My plan is to create an interactive map where users are able to change terrain heights as well as adding water, and such. An idea, very much similar to your solution, but just with way fewer features.

    This post is 7 years old, but I really hope somebody can help me figuring out what and where to look for solutions similar to judah4's that can allow me to achieve this aforementioned goal.

    Thank you, and have a wonderful day all!


    Shortly after I posted this comment, I stumbled across the following solution: https://forum.unity.com/threads/simple-runtime-terrain-editor.502650/

    I have not tested it yet. But if others like me are interested in figuring out how to edit terrain heights on runtime, this might come in handy.
     
    Last edited: May 16, 2020