Search Unity

Easy Roads Mesh Gen FAQ by Kris Development

Discussion in 'Immediate Mode GUI (IMGUI)' started by KrisDevelopment, May 5, 2017.

  1. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Hello,
    My name is Hristo Ivanov and I'm writing this post as a general help/guide to using Easy Roads Mesh Gen v0.3.x and to refer to if needed. I get lots of frequently asked similar questions and I decided to make this thread to help new users get started with the tool.
    Before I continue any further let me mention that there's a Instructions.pdf file in the package which also explains some of the basics.
    With that out of the way let's begin with the first one:

    I don't understand how to add the sidewalk on the roads.
    One of the more important features of the tool is being able to add border meshes to better blend your road/river/etc. with the environment around it.
    This feature is toggled by the Border Mesh option.
    Once you switch Border Mesh on you'll see more options show-up such as Border Shape and Border UVs.
    Border Shape serves as a drawing board and controls the number of vertices and the shape of the borders.
    It reperesents a vertical cut of the right border (looking forward from the first NavPoint ) and you can right click to add new "Key" and then move that key to the desired position. If you have Update Mode set to Realtime you can see the changes being applied instantly.
    Border UVs option determines how the generated borders are unwrapped, or simply put, how the texture on them looks.

    What is Update Mode?
    When you're working with the tool you'll probably need to instantly visualise the changes you make, but once done you'd probably want to reduce the impact of the tool on the performance in the scene view.
    This is where Update Mode comes in.
    It controls how often the tool updates it's mesh and vertices.
    'Manual Update' has little to no impact on the performance since the tool is updated only when you hit 'Apply Changes'.
    'Vertices Only' visualises the position of the vertices but still requires to manually apply the changes.
    'Realtime' is constantly updating the generated Mesh which makes it easier to work with, but it's good to leave it off when you are done.
    EDIT (29.08.2017): As of version 0.5 there is an 'Automatic' Option which aims to optimize the scene performance by preventing non-selected roads from being updated. That ultimately leads to big performance boost and smoother user experience.

    Does Easy Roads Mesh Gen support terrain morphing?
    EDIT (22.7.2020): As of update v0.3.x the tool did not support terrain morphing, meaning it couldn't modify the underlying terrain to fit the shape of the road. However with the latest release (v2020 +) that feature has been added to aid level designers get the terrain shape close to what they would need, manual tweaks may still be required after that.
    You can also "Ground" the points with a given offset. Grounding snaps each point to the underlying collider which makes the road mesh follow roughly the curves of the terrain. Once grounded, the points might need some manual tweaking (for that make sure the Point Control option is set to "Full Manual").

    Converting from v0.2.x to v0.3.x
    When updating from an older version you may get complier errors.
    This could be due to a change in the script names which failed to update on import.
    What I recommend is deleting the scripts associated with the error and re-importing from the asset store.
    That way the scripts will be downloaded with their proper names.
    Most frequent error is:
    Assets/Add-ons/EasyRoadsMeshGen/MeshGen.js(126,37): BCE0005: Unknown identifier: 'NavPoint'.
    and you can either follow the aforementionend method (Delete NavPointGizmos.js and the Gizmos folder and re-importing)
    or renaming the NavPointGizmos script to NavPoint and moving it to the root folder - EasyRoadsMeshGen (However keep in mind that this method, although safer for any scene/prefab references, may be prone to errors).

    Converting to v2018 C#
    As of version v2018 the tool is completely ported to C#. The new C# scripts are put in a differently named folder “EasyRoadsMeshGen_CS” to avoid problems with the old package.

    There are two ways to convert from the old JavaScript tool to the C# version.

    The first way of converting is to completely remove the “EasyRoadsMeshGen” folder from your project, which will make all the objects that have previously had the MeshGen.JS script show up a “Missing” warning. After that you reimport the package from the Asset Store. Then you simply drag the ERMeshGen.CS script on top of the script slot of the message.


    The second way is to delete the old MeshGen.JS script on your GameObject and add the ERHelper.CS script to it alongside ERMeshGen.CS. Then you will need to setup the road’s width, subdivision, UV scale, etc. and after that go to the ERHelper.CS component and click “Fix Nav Points” which will assign all the existing child Nav Points to the navPoint array (as long as they haven’t been renamed manually). The downside of doing things this way is that you will have to manually set the road parameters, however unlike the first way, you won’t be forced update all of the Game Objects that use the old scripts, which allows you to gradually switch to the new package as you use it.

    Does the tool have crossroads
    As of writing this edit (v2020.1 - 22.7.2020) there are ways to achieve crossroads, and have been for a long time, via the "Snap point" functionality, using a pre-made crossroad prefab to which you can snap the road's nav points. More intuitive solutions may become available with future versions.

    Official video introduction to the tool



    For support:
    e-mail:
    hropenmail01@abv.bg
    Twitter: @KrisDevelopment
     
    Last edited: Jul 22, 2020
  2. alex445

    alex445

    Joined:
    May 21, 2017
    Posts:
    1
    Can I generate the road at runtime? In my app, user is allowed to touch the screen and draw a curve with finger, then a road is generated follow the curve. Can I get this function done by your plugin?
     
  3. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Well, it's on the to-do list, but it's going to be a while before I get to implement run-time compatibility, which will also need a in-depth documentation of the different public functions.
    It's important to mention that the tool is currently being ported to C#.
    As of version 0.5.x I don't think you'll get what you need with the Easy Roads Mesh Gen package (real-time roads) unless you personally tweak the code to work in real time for your game (which I'd appreciate if you share your solution with the rest of the community).
     
  4. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    Hi, Nice asset. Easy to use. I am having one issue with LOD. The road texture degrades very quickly with distance and I can't find a way to alter this.
    RoadGenLOD.JPG
     
  5. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    The problem is from the texture and here's how to fix it.
    There's an option in the texture importer called Aniso Level, turn that up above 1 until you're happy with the result (Like in the picture). Another option that might help in addition to that is the Filter Mode, set that to Trilinear.
    Cheers! :)
     

    Attached Files:

    • fix2.png
      fix2.png
      File size:
      106 KB
      Views:
      1,040
    Fibonaccov likes this.
  6. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    Awesome. That did the job. :)
     
  7. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    hi there, just checking this for the first time. I have a question about optimization. Does it automatically reduce vertices when not necessary?
    For instance, if I make a long road straight, no curves, will it generate thousands of triangles or realize that it's flat and just generate a small quantity and adjust the UV for the texture?
     
  8. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    The tool doesn't have an optimization algorithm as it doesn't really need one. If you make a road that is just a straight line, you'd generally use only 2-4 nav points, which makes for around 2-6 triangles top.
     
  9. unity_cwjdyNWLKcKTAg

    unity_cwjdyNWLKcKTAg

    Joined:
    Dec 18, 2017
    Posts:
    4
    Hi Hristo,

    The problem is as follows: we want to have crossings which can all be updated as the project goes along but all the 100s of previously placed ones need to update as well and dynamic crossing doesn't seem to do this. (?)

    I created a dynamic crossing and placed a few but it won't update across the scene after I edit the prefab by adding a model to it, does this only work for custom crossings?
    I figured it was b/c it's a dynamic crossing so I tried turning it into a custom one through the custom prefab editor window. But that also doesn't work (custom crossings only work with mesh input?)
    Do I create a dynamic intersection (T junction between 2 road types) and then export as a mesh and turn that into a custom one?

    Is that a limitation of dynamic crossings then?

    Which also leads me to a workflow question:

    If I decide I want my roads to be 6m wide and that works for dynamic crossings and associated roads but I have to make custom crossings to get proper updating prefabs and later it's decided the roads have to be 6.2m wide and you made all the custom crossings b/c dynamic won't update etc. so you'll have to pretty much decide all of that in advance?


    Thanks!

    -edit- In the tutorial video too, where you edit the railroad, you delete the original and then place a new one where the changes take effect, this is normal, there's no way to have it update on all previously placed instances?
     
    Last edited: Feb 7, 2018
  10. wagnerlee

    wagnerlee

    Joined:
    Oct 18, 2017
    Posts:
    45
    can someone point me to a tutorial as i bought this but the usage is very un clear i am getting a pink road also it is not seem to follow the terrain etc.
     
  11. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Hi,
    On the topic of dynamic junctions, it has been in the development pipeline for a while now and I will be adding that in the next few updates, however for now you have to use only static meshes. Each mesh should have child objects with the SnapPoint script so the road recognizes it as an object to snap to.
    As for the road width/workflow problem, I hope that will be fixed with the dynamic junctions update in the future, but for now I will push an update this week that allows you to lock the width of the snapped points.
     
  12. Schefferbird

    Schefferbird

    Joined:
    Jun 19, 2018
    Posts:
    3
    Sorry Kris! Your introduction video is more like a selling video. Would love to see a tutorial video.
     
  13. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Hello there,
    You are somewhat right about that. As making videos takes a lot of time from other important activities, such as developing new assets and improving old ones, I had to take out two birds with one stone - make a tutorial which at the same time also act as marketing material.
    If you describe what type of tutorial you want to see, I could definitely consider it, or at the very least help you solve a problem you're facing.
    PS: you can also write me an e-mail if you don't feel like your issue should be shared here: hropenmail01@abv.bg OR krisdevmail@gmail.com
     
    Last edited: Jul 17, 2018
  14. Emerald_Eel_Entertainment

    Emerald_Eel_Entertainment

    Joined:
    Mar 30, 2016
    Posts:
    120
    Hello! Is there a way to close a loop once you've finished dragging the points close enough for the loop to be auto completed?

    P.S. Found a bug that happens when you turn Parent Points ON then OFF. It changes how the road looks and makes it irreversible.
     
  15. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Yes, there is a way to close the loop by using the Snap Points (just snap the end point of the road to the starting one).
    About that parent points bug, you can choose not to save the scene and just reload it. It fixes it, however the parent points bug only happens if you have scaled the points. It's something I never really had time to fix as I didn't see it as a big enough issue. If, however, you need it fixed and presents an obstacle to your workflow I will take a deeper look into it.
     
  16. Emerald_Eel_Entertainment

    Emerald_Eel_Entertainment

    Joined:
    Mar 30, 2016
    Posts:
    120
    Thank you for replying. It's not that urgent for me fortunately though it's still worth checking, for future versions. :)
     
  17. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Last edited: Mar 15, 2019
  18. funionnn

    funionnn

    Joined:
    Oct 24, 2017
    Posts:
    1
    Hey!

    I'm trying to figure out how to create road crossings. It looks like I need to model crossings separately, which is fine. I'm getting hung up on the border meshes though. From some older screenshots it looked like you could define a border mesh object, but I can only find the border shape curve editor now - is it no longer possible to define the border shape with a mesh? Is there at trick to matching up the shapes of the border mesh with a crossing that was modeled separately?

    Thanks!
     
  19. bugscuffle

    bugscuffle

    Joined:
    Dec 8, 2015
    Posts:
    73
    [Physics.PhysX] cleaning the mesh failed
    UnityEngine.MeshCollider:set_sharedMesh(Mesh)
    ERMeshGen:UpdateCollider(Mesh) (at Assets/KrisDevelopment/EasyRoadsMeshGen_CS/Scripts/ERMeshGen.cs:1247)
    ERMeshGen:GenerateMesh() (at Assets/KrisDevelopment/EasyRoadsMeshGen_CS/Scripts/ERMeshGen.cs:307)
    ERMeshGen:UpdateData() (at Assets/KrisDevelopment/EasyRoadsMeshGen_CS/Scripts/ERMeshGen.cs:209)
    ERMeshGen:Update() (at Assets/KrisDevelopment/EasyRoadsMeshGen_CS/Scripts/ERMeshGen.cs:161)
     
  20. bugscuffle

    bugscuffle

    Joined:
    Dec 8, 2015
    Posts:
    73
    how do you manipulate it.. so that you can curve it? Is that just lots of NavPoints. I hope you reply. This tool is not bad, once you get used to it. I like the way, so far, that you can add any material you want.
     
  21. bugscuffle

    bugscuffle

    Joined:
    Dec 8, 2015
    Posts:
    73
    UNITY 2018.4 LS But I am getting better with it. It's not bad. The file sizes of the meshes generated are small. Keep working at it!

    MissingReferenceException: The object of type 'ERPointSnap' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEditor.Editor.IsEnabled () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:1030)
    UnityEditor.InspectorWindow.DrawEditorSmallHeader (UnityEditor.Editor[] editors, System.Int32 editorIndex, UnityEngine.Object target, UnityEditor.Editor editor, System.Boolean wasVisible) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1578)
    UnityEditor.InspectorWindow.DrawEditorHeader (UnityEditor.Editor[] editors, System.Int32 editorIndex, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, UnityEditor.Editor editor, UnityEngine.Object target, System.Boolean& wasVisible) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1530)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, System.Int32 editorIndex, System.Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1455)
    UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[
     
  22. bugscuffle

    bugscuffle

    Joined:
    Dec 8, 2015
    Posts:
    73
    I'm giving it a fairly good review.. but better.. if you help us! Not bad compared to the Expensive Easy Roads 3D. The meshes can scaled and rotated after created. Duplicated and made into prefabs. The "UV Scale" (one of the first option boxes) translates into LANES. I guess also, segments of sidewalk or whatever you want for the curb. Leave it to 1 for a two lane road. I don't know whether to make a whole bunch of nodes.. or to stretch them long. Ain't tried it with some asset store cobblestone or other materials, not yet.
     

    Attached Files:

  23. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    @bugscuffle
    Will look into the issue, sorry I didn't see the notification sooner.
     
  24. SSMaster2020

    SSMaster2020

    Joined:
    Sep 15, 2018
    Posts:
    5
    Two questions

    I want to make a roller coaster
    Changing the subdivision will change the shape
    Is there a solution?

    question1.png

    question2.png
     
  25. SSMaster2020

    SSMaster2020

    Joined:
    Sep 15, 2018
    Posts:
    5
    Prefab duplicate and edit
    The original prefab will be changed
    Is there a way to stop it?

    question3.png question4.png
     
  26. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    It's not subdivision, remove "Automatic" update mode. Change it to manual. The tool is trying to figure out the up direction each frame update.
     
  27. karaokefreak

    karaokefreak

    Joined:
    Nov 12, 2013
    Posts:
    96
    Simple question: How do I use the Crossroads? I found the prefab, but I guess it can somehow be used in the editor without just placing it in the inspector, right?
     
  28. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    To be honest, crossroads are not very intuitive with this tool, you need to place them in the scene and use the "Snap" button on the last nav point in order to link that road to the prefab. The tool doesn't place them automatically for you.
     
  29. karaokefreak

    karaokefreak

    Joined:
    Nov 12, 2013
    Posts:
    96
    ah, isee
    Unfortunately, the Snap function does not seem to work (or I am doing something wrong). When I try to use "snap to closest", nothing happens at all.
     
  30. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Make sure you have your Update Mode set to Automatic, or after you hit "Snap", update your mesh. If it's not that, maybe it is a bug and you can hit me up with details at krisdevmail@gmail.com
     
  31. MITTAGE

    MITTAGE

    Joined:
    Aug 30, 2019
    Posts:
    2
    I think we need a script for an object to move along the created road.
     
  32. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    That is actually possible. You can sample the road position after a given distance ranging from "0 - <total_road_length>"
    Add "ERPathTracer" component to your "ERMeshGen" object. Then with code you can ask the ERPathTracer for the "Evaluate" method like:
    Code (CSharp):
    1. OrientationData orientedPoint = myPathTracer.Evaluate(pathIndex, distance, objectLength);
    Where pathIndex is usually zero, distance is the distance along the road, objectLength is the length of the object that is driving along the road such as the length of a car.
     
  33. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    Hi, any advice on this 2 things:
    1) When two points are close together and curved, the border mesh will pinch and overlap. How to do something like this:
    2) Intsead of uniformly placing items along the road, anyway to place things randomly on it?
     
  34. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    To your first question: The road on the image is built from predefined pieces or tiles. ERMG is a bit more "organic" in terms of its shapes, so you have to enter into "Manual" point control mode to shape something like this. Here is my attempt to approximate the image above.
    upload_2021-2-21_1-12-40.png

    As for the second question, You can sample points on the road and place stuff. The "Array" component can help you position things on regular intervals along the road and you can add multiple "Arrays" per road with different distance offsets to achieve irregular placement.
     
  35. Cybermind13

    Cybermind13

    Joined:
    Dec 18, 2018
    Posts:
    13
    Hi, I'm trying to process the underlying terrain, it just won't. First it says it couldn't find any underlying terrain, after that it just does nothing when pressing process terrain.
     
  36. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Hi, could you send a picture of the setup you have and the version of the package you're using?
    This might be a bug, but also could be some missing setup you have to do?
     
  37. Cybermind13

    Cybermind13

    Joined:
    Dec 18, 2018
    Posts:
    13
    Hi, I've used another solution, but I've set up a new project with the same terrain asset, it doesn't output any errors but terrain is not being shaped to fit the road.

    Easy Roads Mesh Gen 2021.2.2
    Unity 2020.3.12f1
    Grassy Valley Terrain 1.0

    2021-11-15.png
     
  38. RobSl

    RobSl

    Joined:
    Jun 26, 2021
    Posts:
    2
    Hello,
    I bougth this wonderfull add-on, but i want to know if and how i can create riverbeds with it, so that the river is "carved" in the terrain..
    I use unity version 2020.3.14f1 with terrain addon Real World Terrain from Infinity Code.

    Kind regards,
    Rob
     
  39. skarmokar

    skarmokar

    Joined:
    Sep 11, 2012
    Posts:
    4
    Can I generate the road at runtime? In my app, user is allowed to touch the screen and draw a curve with finger, then a road is generated follow the curve. Can I get this function done by your plugin?
     
  40. unity_RZds56BPAYFm_A

    unity_RZds56BPAYFm_A

    Joined:
    Mar 18, 2022
    Posts:
    1
    Crossroads just don't work for me. I keep having this problem even if I use the prefab, what am I doing wrong? (see picture)
     

    Attached Files:

  41. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    If you're using URP/HDRP/SRP you might want to go ahead and upgrade the materials to use the appropriate shader.
    Unity's material upgrade tool should take care of that pretty well.

    See this resource:
    https://aussieguy92.com/wiki/unity-101/how-to-update-materials-to-urp-unity-2020/
     
  42. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Yes, runtime is supported and there is "automatic point control" mode that makes the curves for you.
     
  43. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    There is a terrain morphing feature, which you can specify how deep you want to carve into the terrain, as long as the height is above zero. In the inspector you should find "Surface Interaction" section and then specify Offset Value ("depth of your river bed"), after which under "Morph Terrain" specify the Range ("Width of the river bed") and click "Process Terrain"
     
  44. selina0

    selina0

    Joined:
    Oct 24, 2013
    Posts:
    1
    I was not referring to the materials, But to the points not connecting properly, I managed to figure it out though .
     
  45. ToastyJ

    ToastyJ

    Joined:
    Oct 8, 2020
    Posts:
    11
    Hi when entering build terrains mode, the terrain snaps to the road like expected. But when clicking Edit Mode, the changes are undone. How do you lock in the changes? From watching the tutorials its just supposed to save it automatically?

    Also on the intersections the UV mapping seams are slightly busted, you can see a little triangle on the corner, and also the mapping is not tiling across properly.
    This is with the HD upgrade. Is there a known way to fix this?
    upload_2023-11-30_13-29-29.png
     
  46. KrisDevelopment

    KrisDevelopment

    Joined:
    Jul 26, 2015
    Posts:
    36
    Hi @ToastyJ,
    I'm not sure this is "Easy Roads Mesh Gen" you're talking about because it doesn't have the concept for Terrain mode and Edit mode etc. Probably some other tool? Cheers.