Search Unity

World Building EasyRoads3D v3 - the upcoming new road system

Discussion in 'Tools In Progress' started by raoul, Feb 19, 2014.

  1. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Thanks Raoul, I ended up recreating the track and then stamp the terrain and then hide the Easyroad raod. Why is the easy road scripts removed when finilizing terrain? I use Gaia so I will recreate terrain often
     
  2. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    The Finalize option indeed removes all script components from the road network objects. This is what you want to do just before a final build of your project and you probably want to keep a backup. That way you can always make changes in a later stage. The Finalize should not be used if you use the scripting API at runtime for example for AI purposes.

    In your case you want to switch between Edit and Build Mode (the "Build Terrains" button) when the terrain needs to be updated.

    Thanks,
    Raoul
     
  3. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Ok, our game is in early access on Steam, terrain changes every update. Is it fine to build the game without finalizing the terrain?
     
  4. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Also I get this error

    upload_2017-12-1_21-14-28.png
     
  5. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    You can do that. But we usually duplicate the project for a new build. That way we can safely clean up the duplicated build and use that project for the build.

    The Broken text PPtr message to that specific prefab seems package import / update related. It started to appear in 2017. We haven't traced down the issue yet. Temporarily moving this prefab to another location and then move it back seems to solve it. I haven't tested yet a new package export after doing this.

    Thanks,
    Raoul
     
  6. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    4000 posts on this thread! People love EasyRoads:)

    I'm using the beta but I usually do not import demos in most assets to save space. My Project size always hovers around 20gb, and when i have to back it up it takes forever. But i will install the river demo you mentioned:) Sorry to keep popping up in your thread like this - its just such a great asset and i have so many questions because there are so many ways to use it.
     
  7. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    To anyone, the current package will soon be replaced, but for the time being you could import it in a new empty project and first check the demo scene. It is simple but it does include various examples on how you can use the tool, including this river example. But also non road related objects like fences, power lines, etc

    The final package will be the tool only with a minimum amount of assets and a free separate demo project package with additional assets you can also use in your own projects.

    Thanks,
    Raoul
     
  8. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Thanks raoul. Will try your fix later. Btw, Can the framework somehow apply textures to the terrain by the road? Sorry if I have missed this in the docs. Here is a screenshot from anothergame to show what I want to achieve

    upload_2017-12-2_12-14-14.png
     
  9. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi AndersMalmgren,

    You can blend the road shape in the terrain using the terrain splatmap options further below in the Inspector of the selected road. This requires "Update Terrain Splatmaps" in the Build settings to be active as well.

    However, looking at the image I am not sure if this is what you are after. It looks more as if you want to blend the road at the edges with the terrain. This is more road material related. The beta package includes a shader, ER Road Transparency, that can do that. The transparency level is controlled through the road textures alpha channel.

    Thanks,
    Raoul
     
  10. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    I'd have thought you'd use a small chunk of your railroad model (a few meters or so of it) as a "side object" to lay your rail line (with ties and rails) and adjust the terrain automatically after your Gaia stamping and texturing, letting ER3D blend the terrain nicely along the edges. Did you find in the docs how to do that?
     
  11. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi MrG,

    You could indeed do that and it will work well if you only require a single railroad. Otherwise it is recommended to use the custom connection prefab system for that. This way you can integrate the railroad in the road network together with railroad crossings. The current provisional demo project includes an example and the new demo project has a new 2 lane road / railroad crossing example.

    Thanks,
    Raoul
     
  12. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    I know there's a demo scene with a railroad and crossing, but I can't find docs or a tutorial on how to make that from scratch.

    This is @AndersMalmgren 's concept image, but he needs to explain better what he really wants. I think the grey / white is the railroad and the dark lines are some sort of regular road. He's also using Gaia to stamp his terrain before laying in the road and railway.


    This is his railway section:


    The side object video isn't very clear on how this should be done the right way.

    His terrain appears mostly flattened where the town is, so I wonder if he should turn off terrain fixing so the road and rail follow the terrain's slight undulation if there is any.
     
    Last edited: Dec 2, 2017
  13. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    Related to the above, for my own purposes I'd really like an integrated road and rail solution with rail splitters (switches).

    If you've never seen a hump yard in operation, you should go visit sometime...it's rather awesome watching the rail cars turned loose to run free down an incline through a series of automated switches and retarders to put trains together.

     
  14. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I have lots of pieces for my railroad like this end, which I dont think easyrtaods support?

    upload_2017-12-3_1-31-47.png

    Anyway, it works pretty well. Only thing I dont like is that the terrain that Easyroads builds is too flat, it could have added some bumps etc to make it more alive and real looking?

    With easy roads it look like this
    upload_2017-12-3_1-33-42.png

    Would have looked better like this (fast edit by me in terrain tool)
    upload_2017-12-3_1-35-10.png
     
  15. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    I'm going to let @raoul answer from here...I'm sure he can direct you more accurately :)
     
  16. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    In v2 this was done using side objects. But when doing this solely through side objects you are indeed limited to a single track only because side objects do not support connection prefabs like the road system itself does.

    V3 includes two connection types, dynamic built-in crossings but also the custom prefab system based on your own meshes. The package name EasyRoasds3D is a bit misleading here. This system can be used for all sorts of shapes, also railroads. As mentioned, an example is part of the beta package and there is also the Customized Road Network Part 2 video below.

    This video shows how to import a model, set up connections and create road types for these connections. The ties are added as side objects and auto activated for that "road type". When pulling out new railroads the ties will be added automatically.



    So in theory all the railroad pieces can be imported in the system and the railroad network itself can be generated with the tool.

    The set up looks similar as the updated example in the upcoming new demo project which also has an additional floor element.

    railroad.jpg

    The terrain being flat, exactly aligned with the roads/tracks over a certain distance is a direct result of the grid based nature of the Unity terrain object. Those bumps/holes in the terrain in your second image result in the track floating above terrain or the terrain will break through the track, is that right? I don't think you generally want that?

    Have you tried the Road Smoothness options, especially using negative values for Random bumpiness?

    Thanks,
    Raoul
     
    Last edited: Dec 3, 2017
  17. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    This too can be done by creating the splitter sections as connection objects.

    Thanks,
    Raoul
     
  18. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    My track mesh floor is slightly angled like picture shown. As long as the bump is not higher than the angled part it will not bump through the surface of the track

    upload_2017-12-3_12-5-54.png

    Nice, had missed that option. Works fine! Although the values for ofsett is not in meters right?

    upload_2017-12-3_12-15-54.png
     
  19. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Btw, i get this artifact in the terrain

    upload_2017-12-3_12-37-57.png
     
  20. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    The bumpiness values are in meters / Unity units. They are Min Max values.

    Thanks,
    Raoul
     
  21. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Can you give more details? Is that the only place? What do the white surfaces look like? They represent how the terrain will be flattened.

    Thanks,
    Raoul
     
  22. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Yepp, thats the only place.
     
  23. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
  24. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Thank you! That looks all good.

    This seems related to a single terrain point. Given how this works and that I have never seen that happen in the past 7 years, would it be possible to email me this scene (stripped to terrain and road only if you want)?

    Raoul
     
  25. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Sure, I can fix that. Another thing I just found. The road floats above the terrain. My game is a VR game, and because of stereo 3D its very noticeable.
     
  26. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    That would be very much appreciated, that you.

    It is impossible add the roads to the terrain object so it has to be laid on top of it. You can control how much it is raised above the terrain.

    Raoul
     
  27. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You should add a little thickness to it, like I did my railway track. The side of the road will dig into the terrain and hide that it floats

    I will send you it tomorrow to late here now
     
  28. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    If you look at the history of this thread you will see this is only requested sporadically hence a full implementation is lower on the priority list. It also depends on the project and your target platform. In most situations a "flat" road works just fine and is a lot more geometry friendly.

    So it is on the list for dynamic built-in crossings, but roads by themselves can already have custom road shapes / thickness when used with mesh based crossings. The main demo scene includes an example, the single lane road.

    Thanks,
    Raoul
     
    Last edited: Dec 4, 2017
  29. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    In a flat game I can understand its not as important feature. But in VR its very noticable because of stereoscopic vision (perception of depth). And VR will take over 100% of the market in a few years ;)

    edit: I ahve still not got around to send the terrain, need to decouple Gaia etc
     
    Last edited: Dec 4, 2017
  30. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    It is on the list :). At the moment releasing v3 has priority above implementing more time consuming new features. But it will be one of the first things that will be added in v3.x.

    As mentioned, the road system by itself can already handle it without any furtjher code required, but the built-in dynamic crossings needs some work for this.

    We do have Gaia, so it is up to you whether to include a terrain only project.

    Thanks,
    Raoul
     
  31. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Any ETA on that? Sounds a bit time consuming chaning all prefabs, but I think my customers will complain because its pretty immersive breaking with the floating road. Ah allright, I send the terrain as is then.
     
  32. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    A new website is ready which will go live when the new demo project is approved. It includes a survey where users can provide feedback on what they like to see implemented. This topic, roads with thickness, is an item you can vote for. Based on that everything will be scheduled but as already mentioned, as it looks now, it will be one of the first things to add.

    So at this moment I cannot give a precise ETA, on the safe side without guarantees I would say one or two months.

    Discussions like this is one of the reasons why the custom prefab system was added at an early stage. As a user you are not limited and there for do not depend on what is integrated in the system...

    Thanks,
    Raoul
     
    Last edited: Dec 5, 2017
    hopeful and AndersMalmgren like this.
  33. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Hey raoul. I emiled you the project. Hope it will help
     
  34. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    In our project we generate terrain and terrain objects (buildings, roads, ect.) from data, however to save loading time we pre-generate it and store each terrain tile in an asset bundle. When we use the terrain later we load the tiles from these asset bundles.

    I've gotten so far with my trial of EasyRoads that it's time to save the roads to these asset bundles. The problem is that ERRoad is not a UnityEngine.Object, which means that I can't save them straight up into the asset bundle. If I save the GameObject inside the ERRoad, will the EasyRoads script still be included? Like the following code where saveRoads is a List<ERRoad>:

    for(int r = 0; r < saveRoads.Count; ++r)
    info.AddAsset(saveRoads[r].gameObject);​
     
    Last edited: Dec 5, 2017
  35. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi Anders,

    Thank you very much!



    The artifact right at the start of the track turns out to be a combination of the following factors:

    1) The first marker is raised above the ground. (snapping the first marker to the ground eliminates it)
    2) The Preserve Terrain Contours slider is set to 1 (a value of zero completely eliminates the artifact)
    3) The very detailed terrain heightmapscale: size 512, heightmap resolution 1025. Heightmap resolution 513 already looks a lot better

    I will look deeper into this and optimize this further for high resolution terrains like yours.

    Thanks again for reporting this and providing the scene!

    Raoul
     
  36. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi NordstroemSAAB,

    It is not entirely clear what you want to do here and how you want to use the ERRoad object in the final build.

    ERRoad is just a reference to an existing road in the road network.

    So I would think you either want to generate the roads at runtime in which case no ERRoad data is present yet in the asset bundles. Or the road network (all road and crossings game objects) is part of the asset bundle and the ERRoad object (if indeed still required) can be created at runtime through the scripting API.

    Thanks,
    Raoul
     
  37. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    1) yeah; I want the railway track to be raised above the sand dunes so let it be above and then use the terrain tool in easyroad to create the raised embarkment.
    2) See 1
    3) I use 1025 becasue the mountains stamped by Gaia looked a little better.
     
  38. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    I don't want to add the RoadNetwork to the asset bundles, because I don't want to add every road to every tile. I prefer to have a RoadNetwork already in the scene before loading the asset bundle terrains. What I want is the road meshes to be saved in the asset bundles with their respective terrains. I would also like to have the road scripts saved with the road meshes, for the sake of AI pathing in the future.

    We have a lot of terrains that have to be loaded at the same time. Saving everything ready to go in asset bundles was a way to not have to do anything extra during runtime. The terrains are loaded dynamically as you move around the world with big low resolution tiles being replaced with smaller high resolution tiles as you get closer to them and vice versa. That means that there are a lot of terrain loading going on and we really want to minimize the amount of code that has to be run at runtime for the terrain loading.

    I could just finalize the roads, add only the road meshes to the asset bundles and be done with it, but I would prefer to be able to include the road scripts for the sake of being prepared for potential AI pathing in the future.
     
  39. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Yes, I was merely summarizing what causes it so you can test on your end. Train rails are often raised above the ground.

    This will be further optimized so you can do that on very high resolution terrains like yours and still use the Preserve Terrain Contours slider.

    Raoul
     
    AndersMalmgren likes this.
  40. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    So with a road network object already in the scene you want to load individual roads at runtime through asset bundles. If, after being loaded, these road objects are parented to the road network object like in the Unity editor hierarchy , you can still do:

    Code (csharp):
    1. ERRoad road = roadnetwork.GetRoadByName('Road X');
    Will that work?

    Thanks,
    Raoul
     
  41. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    I think you're considering the wrong stage. I'm not asking about the part where the asset bundles are loaded. I'm asking about where they are created. Since asset bundles can apparently only add UnityEngine.Objects I'm wondering if adding road.gameObject will give me both the mesh and the connected script. I have a list of roads and want to add them to the asset bundle. I'm wondering if the following code snippet will do:

    for(int r = 0; r < saveRoads.Count; ++r)
    info.AddAsset(saveRoads[r].gameObject);​

    saveRoads is a List<ERRoad>. Will this add the whole road, with the connected script included or will it add only the mesh?

    Maybe this was a stupid question since the road script is probably a component in the GameObject, but I'm not familiar enough with Unity or asset bundles, thus the question.
     
  42. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    I am pretty certain the game object will be stored in the asset bundle including all components attached to it including the ERModularRoad script if you do not finalize the road network.

    If you do parent the loaded objects to the road network already in the scene you have basically restored the initial hierachy in the unity editor.

    At that point, if you ever need access to the road data for, for example, AI purposes, you can do:

    Code (csharp):
    1. ERRoad road = roadnetwork.GetRoadByName('Road X');
    That is why I asked if that will work for you. Does it? Because I have never tried that but I would think that will work.

    Thanks,
    Raoul
     
  43. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    Thank you. That settles my worries. Even after more than a year of intermittently working on our Unity project I'm still not very used to the way things are done in Unity. Especially when it comes to asset bundle creation, which I haven't done before. I didn't know how the ERRoad class was structured either and was surprised to see that I couldn't just add it to the asset bundle like other things.

    I think for now we'll just keep the roads childed to their respective terrain. That may change at a later stage.
     
    raoul likes this.
  44. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Hey again. A new question.

    I have fixed the terrain with giaia so I can place a building, like this, as you can see the road is going. This is before build terrain with easy road

    upload_2017-12-5_23-13-4.png

    After build terrain

    upload_2017-12-5_23-13-55.png

    As you can see it pretty much destroys the foundation for the building. How can I work around this?
     
  45. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Playing the Giaia session after easy roads is not an option. It works when the road is higher than the Giaia terrain

    upload_2017-12-5_23-16-57.png

    But not when its lower
    upload_2017-12-5_23-17-16.png
     
  46. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Nice align with terrain did it

    upload_2017-12-6_0-1-51.png
     
  47. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi Anders,

    I was just writing a reply when your new post came in. I post it anyway just in case because "Align with Terrain" will create a gap between the road and the terrain. Usually you want to use this together with side object walls or terrain detail mesh overlay just next to the road

    Important here is how the terrain is flattened according the road shape.

    In order to flatten the terrain correctly according the road shape a Minimum Indent value is set. The terrain will break through the road or the road will float above the terrain when using lower values. This is due to the grid based nature of the Unity terrain object.

    This Min Indent value is available in General Settings > Scene Settings. You have a very detailed terrain so it should be low. Just enter 0, it will jump to the minimum allowed value. If this value is lower then the initial value you will probably want to change these Min Indent values for exisiting roads in the scene.

    Any additional objects like the buildings in your images should be aligned with the road when they are positioned inside this Min value. There is no way around that if you want to align objects nicely. But you can align buildings anywhere you want outside these Min value range, that area of the terrain will not be affected.

    You can also take advantage of this. Min Indent values can be tweaked per marker. If you have buildings near the road, you can expand then Min indent values to cover the area. The terrain will be flattened and buildings can be aligned exactly with the roads.

    Thanks,
    Raoul
     
  48. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Thansk raoul, will look at this further tomorrow its 1 in the morning here :D Thanks for all the help
     
  49. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    I just remembered that getting roads by name is not going to be useful to me as several roads are going to end up with the same name.

    This could could be useful though:
    Code (csharp):
    1. ERRoad road = roadNetwork.GetRoadByGameObject(road);
    Does it work even if the passed GameObject isn't childed to the RoadNetwork?
     
  50. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    That by itself should work. And I belief accessing road data will be safe as well. But your workflow breaks the road network hierarchy apart and if that is not restored at runtime it can make the scripting API unreliable. That is however probably more related to creating roads, updating the terrain, etc. through the scripting API. Give it a quick try I would say :)

    Thanks,
    Raoul