Search Unity

Multiplatform Runtime Level Editor

Discussion in 'Assets and Asset Store' started by FreebordMAD, Jun 10, 2014.

  1. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
  2. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    Sorry this will not happen again. I didn't know this would be an issue.
    Will do that now

    EDIT: I have removed the scripts from pastebin as requested
     
    Last edited: Feb 18, 2019
  3. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    Thank you very much! I have purchased the MRLE, I look forward to implementing it in our game!
     
  4. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    I have another question!

    For our game, we want to load two separate pieces of terrain (Let's call them A and B) into a player's in-game view of the MRLE tools. Once these are in, we want the player's brushes and tools to smoothly work across both A and B. For example, say a player is using the MRLE's tools to build a mountain that would fall right in the middle of the border between A and B.

    Is there a way to use the MRLE's tools for players to edit/add smooth and continuous height and terrain edits across the border of two separate terrain objects?

    Thanks!
     
  5. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    Also, is there an easy way to save a terrain asset back into Unity's editor? Say I am running the game scene and I create a level in-game, but I want to save it into a folder (where it persists after I stop running the game) so I can look at it and edit the terrain in the Unity editor. How do I do this?

    Thank you!
     
  6. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    15
    Dear Denis!
    First of all let me tell you, your asset is awesome! My question is, do you see a way to stream not only objects, but the terrains too?
     
  7. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    I figured out solutions to my previous two questions, but I have a new one!

    I saw that you mentioned in your documentation that we can save enormous amounts of space by zipping the level.txt files that store the data. However, I am having a lot of trouble finding how to zip files through Unity. How do I go about having my game automatically zip these files? I know were to add the code, I just am having a hard time finding documentation on how to zip files. Thanks!
     
  8. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    15
    I am zipping my levels too, and it really saves a lot of bytes.... actually sometimes more than 90%.

    add these methods to your level load-save logic code:

    public static string Compress(byte[] buffer)
    {
    using (var memoryStream = new MemoryStream())
    {
    using (var DeflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, true))
    {
    DeflateStream.Write(buffer, 0, buffer.Length);
    }
    memoryStream.Position = 0;

    var compressedData = new byte[memoryStream.Length];
    memoryStream.Read(compressedData, 0, compressedData.Length);

    var gZipBuffer = new byte[compressedData.Length + 4];
    Buffer.BlockCopy(compressedData, 0, gZipBuffer, 4, compressedData.Length);
    Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gZipBuffer, 0, 4);
    return Convert.ToBase64String(gZipBuffer);
    }
    }

    public static byte[] Decompress(string text)
    {
    byte[] gZipBuffer = Convert.FromBase64String(text);
    using (var memoryStream = new MemoryStream())
    {
    int dataLength = BitConverter.ToInt32(gZipBuffer, 0);
    memoryStream.Write(gZipBuffer, 4, gZipBuffer.Length - 4);

    var buffer = new byte[dataLength];

    memoryStream.Position = 0;
    using (var gZipStream = new DeflateStream(memoryStream, CompressionMode.Decompress))
    {
    gZipStream.Read(buffer, 0, buffer.Length);
    }

    return buffer;
    }
    }

    and after having these methods you can convert your level data string to byte, and compress it
    for saving your level:

    byte[] inputBytes = Encoding.UTF8.GetBytes(_regioncombined);

    string mysavestring = Compress(inputBytes);

    and decompress it after loading the saved string:


    byte[] outputbyte = Decompress(_zippedLevelCombined);
    string _levelCombined = System.Text.Encoding.UTF8.GetString(outputbyte);
     
  9. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38

    Thank you very much!
     
  10. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    I am having a bit of trouble still with this; I have a working way to save and load the proper byte arrays, but I can't figure out how to properly convert from byte array back into an ascii string. The byte array (representing the zipped level data) is full of non-ascii characters of course, and I want to be able to convert the byte array into a string. However, when I do this, it is creating a string that is an incorrect representation of the zipped data, rather than the actual ascii representation of the zipped data. How do I properly convert the bytes to a string?

    Thanks so much!
     
  11. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38

    I have been working a bit more, and I think I understand more of my issue. With the zipped data for the level created in the level editor, there are many NUL characters. I know that in the C language that a Null Terminator ends a string, and this is leading me into errors with creating a string representation for this.

    WsdServers, is this code that you use in your system that works when you use it? I think the reason why my data is not matching up with what your code produces is due to the fact that my data can't actually be turned into a proper string due to invalid characters. Does your code use a different approach to compressing that gets around this?

    Thank you for the replies!
     
  12. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    15
    You don't need to do that on your own, remember, the original save progress in the provided examples saves the level data into a txt from a string. So the actual proper way to make your string is provided by the example. You just want to gzip it to a zipped string before actually saving it to txt or anywhere else. You would simply want to rely on the original code in this. Basically what RLE does, is that it stores LevelData (the actual level) and LevelMeta (the metadata of the level) in a combined string, that is devided by a # character. You can use this same approach to keep your level data compatible with the original RLE code.

    Find the OnSave method, that the original example_editor code contains.
    Instead of using the original Save.Delegate method (comment that line out),
    create your string right away with this line:

    string dataAsString = System.Convert.ToBase64String(p_args.SavedLevelData) + "#" + System.Convert.ToBase64String(p_args.SavedLevelMeta);

    then make a SaveLevel method with the code I provided earlier, and pass the dataAsString into the method:

    LevelManager.SaveLevel(dataAsString);


    public static void SaveLevel(string _regioncombined)
    {

    Debug.Log("starting region upload");

    byte[] inputBytes = Encoding.UTF8.GetBytes(_regioncombined);

    string mysavestring = Compress(inputBytes);

    // save your string whereever you like, e.g. DB


    }
     
    Last edited: Mar 8, 2019
  13. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Thanks for helping out @WsdServers!

    @ @MJDevsGames, thanks for purchasing. I'm very sorry for the long time without support!
    Did you manage to zip your levels properly (I have put zip example code on the todo list)?

    Which of your questions are still open?
     
  14. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @WsdServers @FreebordMAD Thank you for your help and responses! Compression now works correctly for us, and we have figured out the answers to our other questions!

    I am really loving the MRLE! Thanks for making such a great system!
     
  15. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    15
    You are welcome @FreebordMAD. My question is open, I was asking if you see any way to stream terrains too besides streaming the objects.
     
  16. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Are you already using multiple terrains? It is not possible to stream parts of a Unity terrain, but if you split your level in sub levels each having a terrain, then you could load only those terrains that the player needs.
     
  17. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    15
    Yes, I am using about 200 terrains in the main scene, which is about 14x14 square kilometres, where you can travel by car, or on foot... it's an open world game, so I wouldn't want to have loading between 2 terrains. That's why streaming would have been good, but then I will use some other streaming solution for the main scene.
     
  18. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    I think I like the MRLE even better than Unity's in-editor terrain editing abilities; The MRLE allows for really exact and nice smoothing of the terrain, and I think it does texture blending better too!
     
  19. hofcsaba

    hofcsaba

    Joined:
    Jul 17, 2013
    Posts:
    8
    Hello all, love the tool, greatest asset I bought so far. I got into some trouble, when tried to save some LE_Objects, with a custom variable, set in "edit mode". How could I load/save this custom variable with the level/LE_Object, when we save/load the level on edit/play mode? I tried to set some objects int property, but cant retrieve it when the level Loads int the _Game scene.
    Cheers!
     
    Last edited: Mar 31, 2019
  20. jiyeongluvyou

    jiyeongluvyou

    Joined:
    Mar 18, 2019
    Posts:
    2
    Hello, thanks for your multiplatform program !
    I have a little problem and question!
    In Unity 5, they add new setting for terrain.

    * please check this link.
    https://blogs.unity3d.com//2018/10/10/2018-3-terrain-update-getting-started/

    So When I made terrain, I should check 'Draw Instanced'.
    Before build unity project, terrain have texture.
    But this program made dynamic terrain and I want build WebGL !
    When I import your asset import the empty unity project and build, all terrain texture is pink!
    like that picture!

    So I add empty terrain in scene before build.
    Then it works, but I wanna know something resolve this task.
    please feedback for me!

    Thanks.
     

    Attached Files:

  21. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Thank you very much ;)

    To save custom script properties or other data you can use the meta data feature. Please check the article below and revert if you still have questions:
    http://www.freebord-game.com/index....time-level-editor/documentation/add-meta-data
     
  22. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Hi thanks for using MRLE. Try switching Draw Instanced off in first place, then switching it on again when your terrain is loaded. See:
    https://docs.unity3d.com/ScriptReference/Terrain-drawInstanced.html
    Do I understand right that you get pink textures in some certain Unity version if you import my asset into an empty project? If so please tell me the exact Unity version that has this problem, then I can try myself.
     
  23. jiyeongluvyou

    jiyeongluvyou

    Joined:
    Mar 18, 2019
    Posts:
    2
    I'm using Unity2018 3.7f. I built "LapiverTools>Example>Scene>LE_Example..." in WebGL.
    When I built it, Terrain was pink. please check this problem. Thank you.
     
  24. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Please send a screenshot of you build settings showing the included scenes. Sounds like you have only some scenes included and those you have do not contain the terrain textures. Therefore, the textures get stripped out while building. When you include the terrain as you wrote in the scene, then the textures are also included in the build.

    Please try to build with all demo scenes marked, then we know for sure if this is an issue.
     
  25. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Just wanted to ask if my previous comment solved your problem?
     
  26. sTorrr

    sTorrr

    Joined:
    Oct 28, 2018
    Posts:
    128
    Is this asset, "Sinespace Virtual", link below, similar, more advanced or less advanced than Multiplatform Runtime Level Editor?
    https://assetstore.unity.com/packages/templates/systems/sinespace-virtual-world-137731

    My goal is to make an MMORPG/RTS game where players can enter level editor within game, such as "Multiplatforform level editor", creating tracks that they share and rate from each other, using spline tool within editor.

    Im also interested in using "Multiplatform level editor" to make the actual game, level design. Does it work well with scriptable 2D sprites, bilboards, 2.5D paperlike 3D graphics, such as seen in games like "Dont Starve"?
     
  27. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I'm not familiar with the Sinespace Virtual plugin and cannot really answer your question. Generally it looks like the tools are just for different purposes.

    MRLE is not designed to be used for realtime multiplayer - however, I know some users here on the forum has integrated it into realtime multiplayer games.
    "creating tracks that they share and rate from each other, using spline tool within editor" - this is exactly what MRLE is designed for - just check this prominent game's workshop: https://steamcommunity.com/workshop/browse/?appid=537340&browsesort=trend&section=readytouseitems

    You can use the MRLE in a 2D environment by using the grid functionalities and the movement axis limitations see: http://www.freebord-game.com/index....time-level-editor/documentation/level-objects
    Search for Translation, Rotation, Scale and SNAP_TO
     
  28. Commandermartin

    Commandermartin

    Joined:
    Nov 8, 2014
    Posts:
    29
    Hey @FreebordMAD,

    I am currently working with your Multi-platform level editor and I have a question about the level loading component. I'm needing to use the loading system slightly differently than your plugin implements. Is there a direct function in the code that I can call, submit a different file location string, and allow the loading process to continue as intended?
     
  29. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Have you already seen the save/load extension?
    https://assetstore.unity.com/packages/templates/systems/mrle-extension-save-load-file-picker-53530
    Do you own it?
     
  30. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    Hello!

    I've been using the MRLE, and it has been working wonderfully; Thanks for making such an awesome product!

    For the game I am developing, I want to be able to have 9 total terrain pieces in-game (In a 3X3 grid) right next to each other. I will be setting them as neighbors in order to make them flow well, but I wanted to ask how I go about making it so that the level editor can make continuous edits across the 9 sectors? (I am not able to just make it 1 big square due to what I am doing; It needs to be the 9 separate ones). Where in the MRLE code can I set the "Current" terrain piece that the terrain tools can edit, and for the "OnLoad" method, where does it find the terrain from? I am having a hard time tracing OnLoad backwards, I am confused where the pArgs are set!

    Thanks so much!
     
  31. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD Sorry if my question yesterday was confusing, I had to leave soon after which caused me to rush typing!

    I think I saw somewhere that the MRLE used to be able to edit multiple pieces of terrain at the same time, but I've been looking through the MRLE code and it seems that this functionality was removed? For the game I am developing, I want to load in multiple sectors of terrain+ their objects/data (9 arranged in a square), and have the player be able to make smooth and continuous edits across them all as if they were neighbor terrains in the Unity editor!

    How can I best go about doing this? Did the MRLE used to have this functionality, or am I mistaken? If it did / still does, how can I find / enable this code?

    If this was never a feature to begin with, how can I best go about implementing it using the MRLE? In general, what systems / parts of the code would I need to alter?

    To give a clear example, say I have these two 200X200 sectors of terrain below. I have a database with 2 slots, one for each of them, which contains their data. For example, my game is set up right now so that I could use the MRLE to choose one and load it into the game. What I want to be able to do is to have some way to load both of them (And ultimately more pieces of terrain to make a full 9X9 square) so that the player can have all of them loaded into the level editor. Additionally, I want the player to be able to make smooth and continuous edits across their borders: So, if a player wanted to create a big hill smack in the middle of their border, the player could do that and it would work / look nice and smooth! Given that I have the string of data for each of them as individual terrain sectors, I would want to take those two (or ultimately 9) strings of data, decode them into these two individual pieces of terrain + objects and metadata, have the player be able to make continuous edits across them, and then save their datas back as 2 separate strings, one for each individual terrain sector.

    Example of this being done inside the Unity Editor (I want players to be able to do this in the MRLE):
    upload_2019-6-22_11-42-21.png

    upload_2019-6-22_11-54-44.png


    Sorry for the lengthy question! How can I best go about doing this, and what existing functionality in the MRLE should I use / alter? Thanks!
     
  32. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Awesome to hear such great feedback - seeing this in an Asset Store review would be epic.

    No worries it was clear already. Unfortunately, I'm a little busy and can answer only with a little delay.

    To get started take a look at the LE_ExampleEditorTerrainOnly scene. It contains a 9-patch terrain and some useful scripts. Especially take a look at the TT_Terrain9Patch script on the TerrainEditable_CENTER GameObject. Most interesting here will be the FixBorders function - currently it makes sure there is no hole between the terrains. You could adapt the underlying TT_TerrainHelpers.FixBorders method to also smooth the neighbor terrain as currently only the center terrain is being edited.

    Further, on the LE_LevelEditorMain GameObject you will find the property LE_ConfigTerrain.CustomDefaultTerrain. If you change this property to any other terrain in the scene before starting the game mode, then you will be able to edit it. If you need to change it on runtime, then you will need to call LE_LevelEditorMain.InitializeDefaultTerrain after changing the property.

    Regarding saving and loading multiple terrain most changes required will be in the LE_SaveLoad class. In the SaveCurrentLevelDataToByteArray method you could instead of gui3dTerrain.TerrainInstance iterate over all terrains in the scene and save the GameObject name and the data with separators in the same string or just give results with multiple strings. This data you can use in the LoadLevelDataFromByteArray method to set the terrain data of the terrains in the scene by searching for GameObject name and then applying the data to the terrains.

    Don't hesitate to revert with further questions - it would be also great to hear if it worked out for you.
     
    Last edited: Jun 25, 2019
    devotid likes this.
  33. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    Thanks for the response! I will try this out, and i'll get back to you with how it goes!
     
    FreebordMAD likes this.
  34. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD

    I've made some good progress so far, and I've gotten the system to physically load in the 9 terrain pieces, position them correctly, and keep track of them. For right now, I am using the MRLE methods to set the center terrain to be editable; So the changes made such as height increases are only applied to the center terrain, and not the surrounding terrains for now.

    Now, I will be working on making it so that the tools affect all terrains that the brush is over, not just the center terrain. I want to make it so that the mouse brush appears when it is hovering over another terrain (As an example, right now the mouse brush vanishes when I hover over the east terrain, it only appears above the center terrain). Additionally, I want to make the terrain height changes to affect multiple terrain sectors; If the mouse brush is painting on the east terrain it should paint terrain there, and if it is on the border between two sectors it should affect them both and make a hill/terrain feature between them.

    I know I can use the 9Patch terrain script to smooth out differences, but how do I go about making it so that the brush affects and responds to the other sectors? What methods do I need to change to make all 9 terrain sectors editable by the brush at once, instead of just one?

    I was looking in the code and I saw that there is a condition that checks if there are multiple pieces of terrain in, which seemed to be for compatibility with an older version of the MRLE that allowed multiple pieces of terrain to be editable at the same time. Did the code used to be allowed to edit multiple pieces of terrain at once? If so, where could I reference that code? If not, what is the best way I can set this up?

    Thanks for your help!
     
  35. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Good to hear :)

    Check the LE_TerrainManager class. You will find methods like PaintTexture, SmoothHeight, ChangeHeight, etc... there. This class is operated by the LE_GenCmdTerrain class which is used by the LE_GUI3dTerrain class. My suggestion would be to create 9 instances of the LE_TerrainManager class, then call the edit methods for each of the terrains via LE_GenCmdTerrain in LE_GUI3dTerrain.

    Could you please tell me which classes and methods you are referring to?
     
  36. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    Thanks for the info!

    I have great news: I just achieved smooth height edits between different sectors of terrain! It looks awesome, and there isn't any sort of seam in between the sector borders!

    upload_2019-7-4_19-31-28.png

    upload_2019-7-4_19-31-37.png

    upload_2019-7-4_19-31-45.png

    I did it by creating a tracking object that kept references to 9 wrapper objects, one for each sector of terrain and data that went with it, like it's terrain manager and location in the 3X3 grid. I passed this tracker object all the way down to the ChangeHeight() method in LE_TerrainManager; I altered this method so that it would figure out which piece of terrain it is (Center, NorthWest, East, et cetera), and would recurs down the method one time, but for it's neighboring terrain(s) (Ex. If the center terrain is being edited, it tells the West terrain to call this method too.) It would only recurs one level to prevent infinite recursion, and I made it copy/alter the p_relativeLocation being passed down to have and offset that would match up for whichever terrain was calling the method, to position changes properly.

    I kind of broke/altered a bunch of other stuff in the process, but I know how to fix all that XD. This was the hard part!

    Thanks for all your aid @FreebordMAD !


    PS: Sorry, I forgot where the section I was talking about was! But its fine since I solved the problem!
     
    FreebordMAD likes this.
  37. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD Quick question,

    Where can I find the scripts / methods that control the visual rendering of the level? I noticed that editing the terrain with the changes I made can cause parts of the terrain to disappear when the editing camera gets close to them: How can I find and adjust the sensitivity of the algorithm which controls terrain rendering in-editor?

    upload_2019-7-5_17-51-7.png

    Thanks!
     
  38. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    15
    Hi Dennis, I would need your sugesstions for my next steps with MRLE... I would like to create objects that has some user-defined elements on them, that should be saved on level editing. Simple example is: a teleport object where user can set and save the target location coordinates into the object while editing, and the data get stored and automatically load when playing the level. What would be the best approach in your opinion?
     
  39. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @WsdServers Hello!

    One thing you could potentially do is to use the Meta Data of the level; There are some methods in the MRLE where you can save key-value pairs to Level data. One approach could be that you could imagine that every special-data object in your map has a unique location, which can serve as its key or ID (You could enforce this too if you want to!). In a level meta data key, you could store a unique object's type and coordinates. When loading a level and its objects, all prefabs of a type are set to be the exact same initially; Once loaded, what you could do is loop through your Meta Data key value pairs, and decode the coordinates / object type for each key value pair (Each "Key" may be pretty complex, and you may need to do some string decoding of your own inside)(Be careful of rounding errors for decoding coordinates; When you save an object's meta data key, I recommend truncating it's literal world position, storing it, and having a "forgiving" decoding algorithm which will find any object close to that position if it exists). When you decode the meta data, you can find an object of that prefab type at that general position, grab a reference to it, and then use the Value part of the key-value pair to set whatever data fields in that object you want at runtime!

    This solution will take a bit of work on your own part, but I think it is the best way to set unique data and fields for each special object you want! I'm planning on using this own method for my own project; @FreebordMAD , do you have any easier suggestions?
     
  40. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD

    I've made a lot of progress with altering the MRLE code to edit 9 terrains at once; I've gotten the raise/lower height tool, the set height tool, and the texture paint tool all working.

    It is the Smooth Height tool that I am having a very hard time getting to make smooth edits across terrain borders. : (

    So, in short, I understand that the smooth height tool is much harder to adapt for use across the borders of multiple terrain sectors, because the change to any single point on the heightmap is dependent on the heights of the points around it. The set / raise /texture paint tools would all find a specific point on the height / texture map, get it's value, and alter the value.

    With the smooth height tool, you can be smoothing a heightmap point which is on the right edge of a terrain sector. If there is another terrain sector to the right of it, that point needs to know about the "nearby" points on the adjacent piece of terrain, and use it's values when calculating average height in the smoothing algorithm.

    -----

    I've been doing a lot of work on this problem, and I've made massive progress. I've used and created systems that allow me to grab the corresponding heights from specific points on adjacent pieces of terrain. When the MRLE smooth tool is finding the surrounding average height to apply to a point on the heightmap's edge, it is able to grab the height values that are on the adjacent terrain sector, if they are "nearby" to that point. I've developed a variety of detection systems to handle edge cases, and I've even made sure to force-synchronize the changes to all 9 heightmaps, so that all of them decide what edits they need to make, and all of them are updated at the same time, so there are no race conditions that mess with the inter-dependency of multiple terrains.

    Still, despite all of this, these blasted seams keep appearing! XD

    upload_2019-7-14_22-12-42.png

    Here's what I know:

    -I don't think there are any race conditions present; The seams created seem to be identical on every retest, and regardless of what side of the border I make the smooth edit on. So, my synchronization code is probably working right!

    -I've messed around, tweaked, and altered the values a ton to make sure I am not messing up an edge or index - 1 or something; This seems to affect it, but not fix it. For example, if I increase the relative offsets for reading the height of a point on a neighbor terrain by 1 (meaning for neighbor terrains I get a height sample from 1 instead of 0, or 511 instead of 512), it seems to actually improve the look and make it VERY close to looking perfect, but not quite; I have not found any other values that can improve it more though.

    -I've done tons of testing, and it seems to be properly deciding where to read / grab height values from; The issue is probably due to me not looking at the problem the right away, and that I am likely missing a fundamental concept about how inter-border terrain smoothing works, and not an error in my code.

    -My algorithm for grabbing the height values of points across the terrain border seems to be working: If you look at this example below (I purposefully made a big height difference over this border here to show it in action), the height changes across both sides of the border are indeed being affected by the large height difference of points on the opposite side of the border, so my inter-border height grabbing algorithm should be working:
    upload_2019-7-14_22-17-39.png

    I've done a ton of tweaking and testing with my code, and everything seems to be functioning properly, yet the seams still appear.

    What my big fear is is that there is something fundamental about how the borders of heightmaps work that I do not know about. For example, I am currently altering / using the height values present at the 0 edges of the heightmaps (so, like when y = 0 or x = 0 on the heightmap, when the point is on the absolute edge). However, could it be that there is some "rule" about how these edges need to be set up, and that I am not taking the special care I need with these edge cases? Or is it something else fundamental I do not know about?

    I know this is a super long shot, but do you have any idea what may be giving me trouble? I will continue to look over and check my algorithms, but from everything I can see and test, they are working as they are meant to, yet there are still seams between the terrains : (

    I know as a last resort I can use the 9Patch script you mentioned above to fix the small seams, but I want to avoid this if possible, because it will still make a very small but still noticeable / "unsmoothed boundary" or feature across all the terrain borders, right? If at all possible, I want to have the edits be completely smooth and seamless across borders like I was able to do for the other 3 tools!

    I'm happy to send updated code if it helps too!

    Thanks so much, and sorry for the very complex question! I am desperate, and I have been working on this for several days to no avail!
     
  41. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD

    As a follow-up to my previous question, I tested by applying the 9Patch script to the terrain, and it is able to patch together the terrains. However, since my smoothing algorithm is imperfect, the 9Patch is having to over compensate, which creates the terrain blip in the picture below (not a seam, but still noticeable).

    Do you know how I can perfect my smoothing algorithm (in my above question) to avoid this situation? Thanks so much!

    upload_2019-7-16_19-36-7.png
     
  42. Commandermartin

    Commandermartin

    Joined:
    Nov 8, 2014
    Posts:
    29
    @FreebordMAD

    What is the correct way to include the textures for a build of a game made with your plugin? I have added additional textures to the project I am working on and they are correctly showing in the terrain creation menu of the level editor and when a terrain is created. However, upon building the game and going to the level editor, the correct number of textures and the correct textures display in the terrain creation menu of the level editor, the created terrain does not receive not the texture and is pink.

    Currently, I have added the required asset of the textures to the build as well as the individual textures themselves but as of yet I have not found a solution to the problem.
     
  43. Commandermartin

    Commandermartin

    Joined:
    Nov 8, 2014
    Posts:
    29
    Just wanted to post the solution for my problem if anyone else comes across it. From what I have experienced upon building the game, the default unity terrain shader does not get included by default. I can only assume that this is because there is no terrain in the scene until the second it is generated by this plugin in runtime.

    While you may be able to find where the default unity terrain shader is and include it in the build, the simplest solution that I found was to add a new blank terrain object (3D > Terrain) from the Gameobjects menu and set it inactive in the hierarchy. This seems to have made unity include the required resources in the build and allowed the texture on the created terrain to display properly without any magenta/pink missing element.
     
    MJDevsGames likes this.
  44. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD

    Great news: I actually was able to tweak a value in my algorithm (In short, I skip reading points on the ABSOLUTE edge, so I do not read from them, but I do write to them still), and when I combine that change with the 9Patch script's fixBorders() every smooth update, it creates the completely continuous effect I was going for! Sorry for the complex previous questions, you can disregard them!

    I have a new question, but this is a much easier one: How can I alter the 9Patch script to have it affect the borders of the center terrain too? Borders between outer sectors are patched (For example, the Northwest sector and West sectors' borders are patched), but the borders of the center sector are not patched (For example, the border between Center and West are not patched). As an additional note, I use the AverageHeights case for fixBorders().

    From what I've seen, this non-affecting of borders on the center terrain seems to be intentional, since it makes sense to be that way for the 9Patch example. My question: How can I modify 9Patch to affect the borders around the center sector too?

    Thanks!
     
  45. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD

    UPDATE:

    I realized why the center terrain borders were not being patched: I was being silly and I assigned all 8 surrounding borders in the 9Patch script, but forgot to assign the center one XD


    TL;DR for alllll these long posts: Everything works now, yay! haha
     
  46. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    @FreebordMAD

    Quick question, for the example editor scripts, where can I find the definition of the interface method for when the createNewTerrain button is pressed? I found it in the interface, but I want to look at where the example defines the behavior!

    Thanks!
     
  47. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    @ @MJDevsGames, @Commandermartin, @WsdServers,

    Gents (and ladies if any) first of all, I'm so sorry for the huge delay!
    I will now answer all your questions in this one post, so give me half an hour and check then for the latest updated version of this post.

    Check for the compiler directive IS_DELAY_LOD_SUPPORTED. To increase performance all changes to terrain data are not fully applied until ApplyDelayedHeightmapModification is called in the LE_GenCmdTerrain command.
    I guess you have figured that out already.

    Awesome work you are a good programmer - modifying the code to that extend is not an easy task!

    Check LE_EventInterface.OnTerrainCreated there is no example of that, but just do something like with all the other events, see the save event here. The call is coming from LE_LogicTerrain.CreateOrRecycleTerrain. I'm not sure if it answers the question, if not rephrase please.





    @MJDevsGames is right the level meta data is the right place for this. Below you will find an article describing how to use the system.
    http://www.freebord-game.com/index....time-level-editor/documentation/add-meta-data



    Good to hear you solved it. In the example projects you will find an object with all materials that need to be preloaded in the game scene similar to your deactivated terrain object.
     
    Last edited: Jul 23, 2019
  48. Beastlytots

    Beastlytots

    Joined:
    Feb 11, 2018
    Posts:
    9
    Has anyone got this asset working with Rewired Input or a Controller? The keyboard shortcuts should be easy to copy for controller, but the parts that rely on mouse clicks and drags might be a challenge. Just wondering if someone has done this and I can buy a script or something. I am running on some tight deadlines for release and could use the time save. Would easily pay $20 for an update or a quick script.
     
  49. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Hi there, my answer to the question asked by @Zed2100 might be interesting - you also could try to contact Zed2100.
     
  50. MJDevsGames

    MJDevsGames

    Joined:
    Jan 9, 2019
    Posts:
    38
    Thanks so much @FreebordMAD !

    One more question: How can I force print statements and errors to be silent and not show on top of the screen in the level editor? For example, this error keeps popping up, but it is acceptable and does not affect things on the game's end. How can I force Debug statements to not show here?

    upload_2019-7-28_11-24-28.png