Search Unity

EasyRoads3D v3 - the upcoming new road system

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

  1. otomat

    otomat

    Joined:
    Nov 8, 2019
    Posts:
    15

    Hi again,

    01.JPG 02.JPG
    01_02_as you can see after importing easyroads v3.1.9.f2 there is only default road and no side object and i think this is the default contains of the package.

    03.JPG
    03_when i try to create the road network from the menu it does not create it and gives an error which you can read in the console.

    04.JPG
    04_ i drag and drop ERRoadNetwork prefab to hierarchy window to make it work.
     
  2. otomat

    otomat

    Joined:
    Nov 8, 2019
    Posts:
    15
    05.JPG
    05_ imported demo scene addon and now all the assets are installed.

    05.JPG
    06_imported hd add on and imported road and side objects and everytihng is now in scene.

    but now scene is so laggy to work with it ,even its so simple like you see in pic 06.

    in my previously built unity project everything works fine now :)
     

    Attached Files:

    • 06.JPG
      06.JPG
      File size:
      1.2 MB
      Views:
      63
  3. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    The main EasyRoads3D Pro package only has one Default Road type.

    It is not recommended to drag and drop the Road network prefab in the scene.

    I just checked the v3.1.9.f2 build that was approved today. Creating a road network from the main menu:

    GameObject > 3D Object > EasyRoads3D

    It works well, there are no errors. Creating roads and adding markers works the same as before, it is not laggy. Can you try the main demo scene?

    So now all presets are imported? That is good to hear, but what did you do different from the previous imports?

    Thanks,
    Raoul
     
  4. otomat

    otomat

    Joined:
    Nov 8, 2019
    Posts:
    15
    i think i made a mistake in the order of import.
    i now imported first demo project (which has older version of easy roads)
    and imported latest easyroads after
    and at last hdaddon
    and it works by GameObject > 3D Object > EasyRoads3D without any lag or freeze :)
    thanks a lot for your kind support.
     
  5. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    249
    Hello,

    I kept on digging to see what the problem could be in relation to the scene file problem I discussed earlier. I've narrowed it down to my vehicle controller in the scene. I'm not sure why this is happening, but in this video you can see the terrain is being built fine when the car is hidden. And it fails when the vehicle is not hidden. Now, what is weird here is that I don't 100% remember having a vehicle controller in the scene for the other failed terrain builds, so I'm not sure if this is the problem for everything. But I know this is 1 of the potential 2 failed terrain problems.

    I've narrowed it down to the colliders on the vehicle. When the colliders are disabled, the terrain builds fine. See below.

     
  6. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Yes, sorry, it was late last night.

    In v3.1.9 the road network object has been renamed. When importing the demo project (with the old name) after the main Pro package Unity will not rename this object but the demo project scripts will point to the old name. That is the reason of the error, the object with the old name cannot be found.

    Unity will update the scripts though. That by itself is a reason to first import the demo project, then the Pro package if you want to be sure the latest version is used. The demo project will be updated as well this week.

    Glad to hear the problem is sorted out :)

    Thanks,
    Raoul
     
  7. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi Freznosis,

    Glad to see you were able to isolate the problem, but that is strange!

    Which vehicle controller is that? I see IRDS.

    Thanks,
    Raoul
     
    Last edited: Dec 17, 2019
  8. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    249
    Hello,

    The vehicle physics are NWH Vehicle Physics. I use IRDS for AI and racing system only. I don't think it's directly related to either of these assets however due to the fact that the actual colliders seem to be causing the problem. However, it could be something else entirely. Maybe something is looking for all colliders in the scene? I'm still investigating right now. But as a work-around I'm using a simple script that disables all cars in the scene and then initiates the build process through the ER3D api.
     
    raoul likes this.
  9. donkey0t

    donkey0t

    Joined:
    Oct 23, 2016
    Posts:
    27
    Thanks for the reply but I still must be missing something. I'm still not sure what the Permiter values mean but I set them all to 10 to try it and pressed the Reset All Road Types and Objects but still I have all sorts of items over the road. Is there some sort of order (to the masks?) where the road will always win?
     
  10. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    There is no order. These perimeter values are VS component specific. The first thing to check is whether the values are correctly set for the roads. This can be done in the Inspector after selecting a road. These controls are located near the bottom. Changing for example the grass perimeter value here should have an instant effect, also in Edit mode. If not then the road itself can be selected in the hierarchy. The specific VS component should be visible in the Inspector. The perimeter values can be verified by selecting the grey VS sphere handles on the road. Is all that in place?

    Thanks,
    Raoul
     
  11. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Rowlan likes this.
  12. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,428
    I created two roads with the same road type. This road type is Asphalt with lines in it.
    I decided I didnt want lines in it anymore. So I went to edit road type and changed the road material out to no lines.
    As you can see in the picture it updated one road but not the other road. I hit the button update scene too.
    Everytime i hit that button I get with this error.



    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <567df3e0919241ba98db88bec4c6696f>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <567df3e0919241ba98db88bec4c6696f>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <567df3e0919241ba98db88bec4c6696f>:0)
    EasyRoads3Dv3.QDQDOOQQDQODD.SetIsRoadShape () (at <bdacb6ae76884e7aadfd6868b11e2371>:0)
    EasyRoads3Dv3.QDQDOOQQDQODD.UpdateTimestamp () (at <bdacb6ae76884e7aadfd6868b11e2371>:0)
    EasyRoads3Dv3Editor.OQDODOCCOD.OCOOQDOQDD (EasyRoads3Dv3.ERModularBase scr, EasyRoads3Dv3Editor.OOQCDODQDD eScr, System.Collections.Generic.List`1[T] roadTypes, System.Collections.Generic.List`1[T] QOQDQOOQDDQOOQ, System.Collections.Generic.List`1[T] sidewalks) (at <e7d39089704443f289d79ffeb8b68a55>:0)
    EasyRoads3Dv3Editor.ODOQDDQOOQ.OODDCDQCCC (EasyRoads3Dv3.ERModularBase scr, EasyRoads3Dv3Editor.OOQCDODQDD eScr) (at <e7d39089704443f289d79ffeb8b68a55>:0)
    EasyRoads3Dv3Editor.OOQCDODQDD.OnInspectorGUI () (at <e7d39089704443f289d79ffeb8b68a55>:0)
    UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
     
  13. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi Shadowing,

    How did you edit the road material? These are road types from the HD Roads package. This package includes road types with no lines. Or did you change the material for the already selected road type and then click "Update Scene Instrances"?

    Regarding the error, which version do you use? Does this happen in the latest v3.1.9f2? It should be fixed in this version.

    Thanks,
    Raoul
     
  14. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,428
    The material that was already there and the material I replaced it with are both materials from the HD Roads package.
    I clicked on the Gear symbol, then clicked the road type and changed out the material with another HD Roads material.

    Ya i guess i don't have the most recent version. I updated it like a few weeks ago though.
    updating it now.
     
  15. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Yes, that is what I though I just wanted to make sure what the exact steps are.

    In any case, v3.1.9f2 does include a couple of fixes for issues in v3.1.9f1. I looked at the error, SetIsRoadShape () in v3.1.9f2 cannot throw an ArgumentOutOfRangeException error.

    Thanks,
    Raoul
     
  16. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,428
    Thanks @raoul good support as always.

    This is a issue I come accross now and again. Smooth function on ER doesn't fix it.

     
  17. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,428
    oh never mind guess im suppose to hit smooth indent area button
     
  18. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Getting the terrain really smooth with those steep edges is hard anyway.

    The v3.2 beta includes some ways to deal with that.

    https://forum.unity.com/threads/eas...-new-road-system.229327/page-155#post-5263190

    This was already possible, but now these side objects can be setup in a way they will be auto generated based on the terrain profile. In the video walls are used, but this can also be a shape with a similar rock material with UVs matching the terrain so the generated rock mesh blends with the terrain. This will be smooth.

    Thanks,
    Raoul
     
  19. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,428
    should Expand setting only allow max 3 under Terrain splatmap settings?
    Its the highest it lets me set it.
    Isn't that the distance from the road it will paint the texture?
     
  20. almirb

    almirb

    Joined:
    Oct 1, 2015
    Posts:
    6
    Is It possible to import OSM data and create roads in runtime?
    Thanks!
     
  21. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    The Max Expand level should be 5 and because this is related to the trerrain splatmap this value represents cells of the splatmap control texture resolution. It is not the distance in Unity units.

    Thanks,
    Raoul
     
  22. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi almirb,

    The OSM import option is currently only available in the Unity editor because crossings are not auto created yet. So at runtime this would only import the roads, no crossings.

    Thanks,
    Raoul
     
  23. AdamSingle

    AdamSingle

    Joined:
    Apr 18, 2013
    Posts:
    20
    Thanks for the reply Raoul,
    It looks like I didn't have the latest. I can now create new Road networks from the editor menus. But I seem to still get an error when calling
    var roadNetwork = new ERRoadNetwork();

    There isn't much in the callstack, but here it is anyway

    ArgumentException: The Object you want to instantiate is null.
    UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:374)
    UnityEngine.Object.Instantiate (UnityEngine.Object original) (at C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:231)
    EasyRoads3Dv3.ERRoadNetwork..ctor () (at <44db4b557a5242b59c9b46f9ab327024>:0)
     
  24. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi AdamSingle,

    Thank you for reporting that, this should have been updated as well in v3.1.9f2.

    This is related to prefab name changes in v3.1.9f1. Specifically: /Assets/EasyRoads3D/Resources/ERRoadNetwork. In older versions this was named "ER Road Network". When upgrading to the new version Unity will not rename this prefab. That is why the error is thrown, the "ERRoadNetwork" prefab cannot be found.

    In v3.1.9f2 This situation is dealt with when creating a road network in the Unity editor, but not when creating it through the scripting API. It will be fixed in the next update, for now could you try removing the spaces manually from "ER Road Network"?

    Thanks,
    Raoul
     
    AdamSingle likes this.
  25. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,014
    Hi,

    I purchased the ER3D Pro Add On - HD Roads... upon import, this add on wants to delete a lot of files (such as shaders, materials, the delaunay stuff in the lib folder, etc but ALSO EasyRoads3Dv3.dll).

    Is this the intended behavior?
     
  26. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi Metron,

    The HD Roads package does not include script components. How does the package import want to delete these main EasyRoads3D Pro files?

    To be sure you could first do a test in a new project with both packages. First import EasyRoads3D pro, then the HD Roads package. It should work fine.

    Thanks,
    Raoul
     
  27. otomat

    otomat

    Joined:
    Nov 8, 2019
    Posts:
    15
    Hi again Raoul, can you guide me with using custom geo as a mesh terrain.
    i imported a custom geometry , i assigned it to mesh terrain section but road do not snap and i can not see that geometry in selected terrain list.
    What shall i do to snap the road to imported geometry.
     
  28. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi otomat,

    I just double checked this with a simple Unity plane primitive assigned as the Mesh Terrain. When adding new road markers, they do snap to the plane object. Does the mesh terrain has a collider attached?

    Or is your Mesh terrain not flat and do you want to snap the road to this shape? That is only to a certain extend possible, there terrain shape should be gently rolling without abrupt height changes. Snapping the road to this type of surfaces can be triggered through the scripting API and the ERRoad class: SnapToTerrain(bool value) or SnapToTerrain(bool value, float offset) where offset is the height distance relative to the terrain mesh at that position.

    Thanks,
    Raoul
     
  29. otomat

    otomat

    Joined:
    Nov 8, 2019
    Posts:
    15
    Thanks a lot Raoul, adding mesh collider simply solved the situation. My terrain mesh is mostly flat with little height changes. And what i try to achive is just to place road lines , markings and side objects to my custom mesh terrain because main road is just tiled concrete. Thnaks a lot for your helps.
     
    raoul likes this.
  30. ibearjp

    ibearjp

    Joined:
    Sep 24, 2014
    Posts:
    14
    Hi, sorry if this was asked before, i did a search on here and didn't find what i was looking for.
    Is there a was to export and import the entire road network from a scene to another scene?
    Thanks.

    (Still on V2)
     
  31. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi ibearjp,

    In v2 road objects are all individual objects not part of a road network like in v3.

    But the same recommended workflow can be used as for v3, load both scenes in the hierarchy. But instead of dragging the main road network object from one scene to the other, this can be done for all individual road objects in v2. Only save the target scene. The same road objects should now be part of both scenes.

    Thanks,
    Raoul
     
    ibearjp likes this.
  32. volfase

    volfase

    Joined:
    Nov 15, 2016
    Posts:
    35
    why is this happening holes in road how that can be fixed?
    and can i set physic material for diffirent roads/road materials?
     
    Last edited: Dec 29, 2019
  33. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi volfase,

    It is impossible to add roads to the unity terrain object so they have ti be laid out on top of the terrain.

    First if all is this in Edit Mode or build mode? In Edit Mode the terrain is not adjusted to the road shape.

    If this is in Build Mode, then what is the "Raise" level in the Inspector? Which shader are you using, and what are the terrain specs, heightmap resolution and terrain size? There must be enough terrain points available to accurately adjust the terrain to the road shape.

    Do you mean physics materials for road types, in General Settings > Road Types? It was there but currently not active because there was a problem with that. I will check this.

    Thanks,
    Raoul
     
  34. GCat

    GCat

    Joined:
    Jul 31, 2012
    Posts:
    212
    do you recommend using easyroads on multiple terrains like (4 tiles x 1024)
    or on one terrain full size (4096) ?

    I'm asking because seems its harder for the road to deform the mesh of the terrain if its just one big terrain
     
  35. volfase

    volfase

    Joined:
    Nov 15, 2016
    Posts:
    35
    First if all is this in Edit Mode or build mode? its build mode
    what is the "Raise" level in the Inspector? 0
    Which shader are you using? if you mean in road i use default which look like be EasyRoads3D/Unity 5 Standard
    terrain specs, heightmap resolution and terrain size? heightmap = 513 terrain size = 1000x1000
     
  36. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi GCat,

    The end result should be the same but 4097 heightmap resolution indeed appears to be heavier to process. In general it is recommended to use multiple terrain tiles, in this case that could be 4 x 4 terrains, resolution 1025.

    Thanks,
    Raoul
     
  37. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi volfase,

    Thank you for the additional info. Looking at the road shape and the terrain specs, the terrain settings should be fine. But a Raise level of 0 means the road geometry is exactly at the terrain height. In general that will result in z-fighting.

    The specific EasyRoads3D shader uses an offset and that is probably why the Z-fighting is only noticeable near the cam. This offset is more intended to deal with the terrains LOD system and to prevent parts of the road disappearing below the terrain. But depending on the offset strength it can also help with z-fightinh issues. Does the problem indeed disappear when using a Raise value of 0.01 or 0.02?

    Thanks,
    Raoul
     
  38. volfase

    volfase

    Joined:
    Nov 15, 2016
    Posts:
    35
    setting Raise value to 0.01 fixed it thanks
     
    raoul likes this.
  39. Untitl3d

    Untitl3d

    Joined:
    Jun 20, 2019
    Posts:
    7
    Hello @raoul ,
    I'm relatively new here & It seems it is an amazing asset but one thing is confusing.
    Normally after v2 you have v3, or after v3.1 you will have v3.2. Or if v3.2 is beta then there should be v3.2 final.
    I noticed V3.2 beta is not final, but there is also a v3.3 alpha and both are available at the same time.

    The question is, Does that mean v3.2 is now safe to use in long run & is v3.1 obsolete? it would be great if you clarify the whole roadmap of Easy Roads.
     
  40. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi Untitl3d,

    With regard to both betas and alphas being available,for example Unity 2019.3 alpha was already available when Unity 2019.2 was still in beta. The same for Unity 2020.

    In the case of EasyRoads3D the v3.3 alpha was previously v3.2. There are some new features that are complex and require require more work to complete, motorway on/of ramps and materials and more options for different road types on Flex Connectors. The initial schedule for V3.3 was side object related. These new features also cover the Unity 2019.3 terrain update supporting holes which can be used for tunnels.

    Since the side object update is less complex and to move forward faster with new features (like support for tunnels) and final releases, the v3.2 and v3.3 features sets are switched. The new v3.2 features will be primarily side object related. The previous v3.2 features are already actively used that is why the new v3.3 is already available as alpha releases. Both versions are being worked on.

    v3.1 is not obsolete, that will be the case when v3.2 has fully replaced v3.1 on the Asset Store. The current v3.2 beta should work fairly well although there are some small issues and some new v3.2 features must first be added. Once that is done, it will be part as a separate package in the Asset Store import. Until then they will be available through our website. That is an indication of the state. Some people do not mind the glitches that come with new features, they already want to use them and usually they also provide good feedback. Others want a more stable experience while there is also a group that even wait longer.That is also the case with the Unity software itself.

    Thanks,
    Raoul
     
    dsilverthorn and Untitl3d like this.
  41. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    403
    Still I can't figure out how to move a terrain in the middle of rail roads. I've checked that demo you mentioned before but still I can't do this. I want to do this by "get properties" action from PlayMaker.
     
  42. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi Crossway,

    I cannot find a recent history of this. How do you want to move the terrain in the middle of rail roads?

    The demo Includes a railroad example based on the railroad crossing prefab also used in the demo scene. Because the railroad is generated as a "road" the terrain is flattened accordingly just like for roads.

    Thanks,
    Raoul
     
    Crossway likes this.
  43. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    403
    Hi. Sorry I meant train not terrain :oops: I just need to move forward an object in the middle of a road. Can't figure out how can I get middle position of a road by PlayMaker get properties method.
     
  44. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    I am not familiar with Playmaker so I cannot really help with that part.

    The data is available through the scripting API. If you only need all middle points, ERRoad.GetSplinePointsCenter() can be used. This returns an array of Vector3.

    Code (csharp):
    1. // get a reference to the road network already in the scene
    2. ERRoadNetwork network = new ERRoadNetwork();
    3.  
    4. // get the "road"
    5. ERRoad road = network.GetRoadByName("the rail road object name");
    6. //or
    7. ERRoad road = network.GetRoadByGameObject(GameObject object);
    8.  
    9. // Get the middle points
    10. Vector3[] points = road.GetSplinePointsCenter();
    Thanks,
    Raoul
     
    Last edited: Jan 4, 2020
  45. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    362
    I'm working on a tool to auto-create roads and paths in any multi-terrain environment, mainly because there's no such tool available for Unity, so I had to create my own system using various scientific papers. The system is promising, works very well and can even create tunnels and bridges without manual assistance.

    I have a couple of problems, though, when trying to connect roads, and I'd be very grateful for some pointers/advice. This is a section of the terrain (not all terrains are loaded here):

    Screenshot 2020-01-03 at 17.26.32.png

    The blue spheres are village gizmos. Generating the road network yields this:

    Screenshot 2020-01-03 at 17.28.56.png

    As a preliminary optimisation, each road is walked from its origin until it either reaches its destination or an existing road. This, however, results in situations like the following:

    Screenshot 2020-01-03 at 17.43.45.png

    As you can see, the road from the left is crossed by the road from the right, which then runs in parallel for a few markers until it's terminated when the two roads reach exactly the same point. Here's another example:

    Screenshot 2020-01-03 at 15.41.05.png

    This can of course be fixed by calculating the exact point of intersection, but as EasyRoads Pro already has facilities for connecting roads automatically (
    ConnectRoads(from, to)
    and
    ConnectRoads(from, fromIndex, to, toIndex)
    ), I thought I'd use them.

    This is the code for adding a new road to the road network:

    Code (CSharp):
    1.  
    2.         void AddNewRoad(string roadName, VillageData start, Vector3[] path, VillageData target)
    3.         {
    4.             ERRoad[] roads = network.GetRoads();
    5.             ERRoadType roadType = network.GetRoadTypeByName(mainRoadTypeName);
    6.             ERRoad road = network.CreateRoad(roadName, roadType);
    7.             road.SetSplatmap(true, 5, 0, 0, 1f);
    8.  
    9.             for (int i = 0; i < path.Length; i++)
    10.             {
    11.                 Vector3 pathPos = path[i];
    12.                 if (Vector3.Distance(pathPos, start.position) < start.radius) continue;
    13.                 foreach (ERRoad existingRoad in roads)
    14.                 {
    15.                     Vector3[] existingPositions = existingRoad.GetMarkerPositions();
    16.                     for (int j = 0; j < existingPositions.Length; j++)
    17.                     {
    18.                         Vector3 existingPathPos = existingPositions[j];
    19.                         if (Vector3.Distance(pathPos, existingPathPos) <= 4f)
    20.                         {
    21.                             //road.AddMarker(pathPos);
    22.                             network.ConnectRoads(road, existingRoad);
    23.                             return;
    24.                         }
    25.                     }
    26.                 }
    27.                 if (Vector3.Distance(pathPos, target.position) < target.radius) return;
    28.                 road.AddMarker(pathPos);
    29.             }
    30.         }
    31.  
    However, the code fails to connect any paths at all:

    Screenshot 2020-01-03 at 15.44.01.png

    I would have expected T junctions to be inserted where appropriate, but instead long sections of perfectly straight roads are created across the terrain, which obviously is wrong.

    So, my question is: why doesn't ConnectRoads connect the roads? I've tried both variants of the method, with exactly the same result. The road type used above is "Dirt Track Grass". Do I have to create intersection objects first? What am I missing?

    Very grateful for any pointers.
     
    dsilverthorn likes this.
  46. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    Hi PeterB,

    Based on your code, network.ConnectRoads(road, existingRoad) will merge the two road objects into one road object when the road types match.

    For inserting X and T Crossings indeed crossing prefabs that match the involved road types must exist. Below are some pointers.

    First a reference to the specific crossing in the resources folder is required.

    ERRoadNetwork class

    public ERConnection[] GetConnections()

    public ERConnection GetConnectionByName(string name)

    Then you can either attach crossings directly to the road

    ERRoad class

    public ERConnection AttachToEnd(ERConnection sourceConnection, int connectionIndex)

    public ERConnection AttachToStart(ERConnection sourceConnection, int connectionIndex)

    Or the crossing can be instantiated in the scene followed by connecting the roads

    ERRoadNetwork class

    public ERConnection InstantiateConnection(ERConnection sourceConnection, string name, Vector3 position, Vector3 eulerRotation)

    Connect roads to already existing crossing objects

    ERRoad class
    public bool ConnectToStart(ERConnection connectionObject, int connectionIndex)

    public bool ConnectToEnd(ERConnection connectionObject, int connectionIndex)

    The logic of which connection index to connect to is currently something you have to code. The ERConnection class has for example something like:

    public Vector3 GetLocalConnectionPosition(int connectionIndex)

    which can be useful to find the nearest crossing connection to the road.

    Hope this helps.

    Auto creating roads is on the schedule, we have experiemented with that in the past and it was recently requested again. It is a logical next step after the new v3.2 features that include auto creation of tunnels and bridges where side object placement no longer depend on marker positions.

    Thanks,
    Raoul
     
    Last edited: Jan 28, 2020
    PeterB likes this.
  47. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    362
    Many thanks, Raoul, for the info and for the quick reply. This data is exactly what I need.

    I'd also like to ask how to add Vegetation Studio Pro splines to the roads.

    It's interesting that you're planning built-in support for autogenerated road networks in a future version. I remember a commercial product by a third party, advertised as an upcoming beta with great panache, about three years ago. Nothing came of that effort, however. Something integrated with EasyRoads by you will have a much greater chance of actually being completed. If you'd like a look at my code, please PM me.
     
  48. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    403
    Thanks. How can I store the values of this array?

    Also in the line 2, is that new instead of New?
     
  49. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    @PeterB, Vegetation Studio Pro can be activated in General Settings > Terrain Management. Vegetation Studio Pro controls will be visible when this package is imported in the project. After setting the global perimeter values, these values can be adjusted per road type in General Settings > Road Types and also per individual road after selecting that road in the scene.

    We experimented with pathfinding quite a while ago. After receiving this request I looked it up. It was very early stage no roads yet. Meanwhile roads are generated but it does need more work, especially in steep hilly areas. Thank you for your offer, I will PM you.

    Raoul
     
    PeterB likes this.
  50. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,928
    @Crossway, I suppose this is related to Playmaker? I am not sure how that would work. All middle points are in the points vector3 array.

    Yes, sorry, "new" not "New".

    Thanks,
    Raoul
     
unityunity