Search Unity

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

World Building EasyRoads3D v3 - the upcoming new road system

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

  1. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi julianr,

    Glad to hear you got that working.

    In your situation, if the road was not connected yet toi another crossing, then you could indeed also instantly take out a new road from the roundabout connection instead of creating a new road object first. It will have the sidewalks added.

    Thanks,
    Raoul
     
    julianr likes this.
  2. karaokefreak

    karaokefreak

    Joined:
    Nov 12, 2013
    Posts:
    96
    Hi again

    1)
    Yes, I originally wanted to create my own road type in Blender in order to import it into your system, so I can lay my streets along the terrain shape. But you say that does not work because of the intersections. That is a pity.

    2)
    What I meant is your third road asset ("Easy Roads Mesh Gen"). I am willing to buy it if it helps me creating what I explained above - I need dual lane streets and fitting crossings. I can make the textures for those streets and crossings myself. So if that tool is the answer to my problems, I'll buy it in an instant.
    I could also live with a mixed option option of Blender-made intersections and roads made with your tool. As long as I can design the appearance, I am fine with it.

    3) About the river option
    First I pick the River in the street type menu in the inspector. Then I press on the "Add New Object" button, just like I do it when I want to make roads. After that, I press Shift + click on the terrain. A marker appears. But when I try to Shift + click again to determine the direction of the river, nothing happens.
    Error-message :

    Code (CSharp):
    1. Parameter name: index
    2. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <fb001e01371b4adca20013e0ac763896>:0)
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <fb001e01371b4adca20013e0ac763896>:0)

    4) It seems to me that I can't reproduce the Bridge Error. But I used a road witrh the "siumple bridge" object, and when I changed the Wirth of the road in the according road menu, it lost all textures. But as of now, I cannot reproduce that, since ai don't remember which street type that was.
     
  3. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi karaokefreak,

    It depends on what you mean with road type. If it is a specific shape, then that can be done as mentioned in my previous reply by importing the model as a connection object: General Settings > Crossing / Connection Prefabs > Custom Prefab Editor Window.

    If it is a road section that must be repeated and no crossings are involved, then it can be created as a procedural side object.

    We do not have an asset that is called "Easy Roads Mesh Gen". There is an asset called that way but it is not ours and it does not generate meshes for EasyRoads3D, we can see the name is a bit misleading considering the history of the packages.

    I just tested the river "Road Type" in the demo scene by creating a new instance, it works well, no errors. Does it also work well for you in the demo scene?

    The error you posted does not include a clear reference to EasyRoads3D. Is that the full error?

    Ok, so the road width was changed, not the bridge width. The bridge side object is based on a procedural side object type. This means the material of the prefab in the project folder is used that is assigned in the Side Object Manager as the Source Prefab for the bridge. I cannot see the link between changing the road width and the material of the bridge being broken afterwards.

    It will be a matter of checking this specific source prefab material and comparing it with the material assigned to the bridge instance in the scene.

    Thanks,
    Raoul
     
  4. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Hi, is their an easy way to get and set the road creation nodes. I'm using this with RSGK( racing game kit) and would like to sync up it's track nodes with the road nodes
     
  5. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi keithsoulasa,

    That can be done through the scripting API

    Code (csharp):
    1. // get a reference to the road network in the scene
    2. ERRoadNetwork roadNetwork = new ERRoadNetwork();
    3.  
    4. // get a reference to the road
    5. ERRoad road = roadNetwork.GetRoadByName("road name");
    6.  
    7. // or
    8.  
    9. ERRoad road = roadNetwork.GetRoadByGameObject(gameObject);
    10.  
    11. // get the position of the node at index 2
    12. Vector3 node = road.GetMarkerPosition(2);
    13.  
    14. // set the node at index 2 according Vector3 position
    15. road.SetMarkerPosition(2, position);
    Thanks,
    Raoul
     
  6. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Hi raoul,

    Maybe I didn’t describe it clearly,
    Now I use :
    Code (CSharp):
    1. public void InsertMarkerAt(Vector3 pos, int index)
    But in some cases, I don’t know where the Marker I inserted will be, so I don’t know the index of the Marker.

    I searched the API documentation, but I couldn’t find a function to insert a Marker anywhere(index cannot be determined) and return the index of the Marker.
    So I use the following method:
    Code (CSharp):
    1. int markerIndex = road.roadScript.ODQDDDCQCQ(position);
    2. road.Refresh();
    same as:
    Code (CSharp):
    1. public void InsertMarker(Vector3 pos)
    2. {
    3.    this.roadScript.ODQDDDCQCQ(pos);
    4.    this.Refresh();
    5. }
    But it can only take effect once.
    I have one quesstions:
    1. Is there a way for me to insert a Marker anywhere on a road with multiple Markers, and then return the index of this Marker?

    Thanks,
    Zhang
     

    Attached Files:

    Last edited: Jul 22, 2020
  7. Himanshuchahar

    Himanshuchahar

    Joined:
    Apr 15, 2016
    Posts:
    42
    Hi Raoul,

    Hope are doing fine.
    I am getting an issue with roads texture, roads doesn't appear properly around camera.

    road.PNG
     
  8. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi Zhang,

    I think you made a comment about returning the index after inserting a marker a couple of days ago and I asked if that was a request. The inserted index will be returned in the next update, that is already added. If you want I can send an update so you can test. Which version are you using?

    Thanks,
    Raoul
     
  9. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi Himanshuchahar,

    Your setup is one of the trickiest for road creation, a very hilly terrain and a road with sharp curves and height differences.

    It is impossible to add detail points to the terrain so to adjust the terrain accurately to the road shape, the terrain must have enough terrain points available in that area. The higher the heightmapscale of the terrain (terrain size vs heightmap resolution) the more limited you are with the road shapes like in your image.

    A good way to test this is start a new scene with a new hilly terrain and add a road. Then change the heightmap resolution and see how that affects the results.

    Also, when two roads are near to each other and not connected, like in your image, chances are that adjusting the terrain to one of the roads will result in breaking the terrain through the other road. This will potentially happen when the heightmapscale of the terrain is higher then half the distance between the two roads.

    Thanks,
    Raoul
     
    Last edited: Jul 22, 2020
  10. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Hi Raoul,

    Good morning,
    Yes,my version is EasyRoads3D Pro v3.1.9.f4.
    Is the update sent by email or assets store?My road construction project is stuck here.;)

    Thanks,
    Zhang
     
    Last edited: Jul 22, 2020
  11. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    I have to check the current status and prepare the build. I will send an update later today in a PM.

    Meanwhile, the marker index can be found by going through all markers and find the one that matches the passed position for the newly inserted marker.

    Thanks,
    Raoul
     
    qpuilie likes this.
  12. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Hi raoul,

    I also want to provide an error regarding the documentation:
    ducumentation:
    public Vector2[] GetRoadShapeNodes()
    but in fact the definition is:
    public Vector2[] GetRoadShapeNodes(int markerIndex)
    I'm weak in english,hope you forgive me for inadvertently offending.I like EasyRoads very much.

    Thanks,
    Zhang
     
  13. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi Zhang,

    GetRoadShapeNodes() is indeed marker index specific. I will update the documentation, thank you! And glad to hear you like the tool.

    Raoul
     
  14. zafery

    zafery

    Joined:
    Sep 11, 2014
    Posts:
    9
    Hi,

    I have Easy Roads Pro v3. Can I use this plugin without terrain? it seems I can but there is a warning "EasyRoads3D: No terrain found, for standard road networks at least one terrain object is required".

    thanks.
     
  15. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi zafery,

    Generating road networks on a Unity terrain object is what this tool mainly does, hence the warning message.

    But it is possible to create roads without a terrain object, markers will be added based on the scene cam orientation. Or do you have a mesh terrain in the scene? In that case this terrain can be assigned to General Settings > Scene Settings > Mesh Terrain. Updating the mesh terrain to the road shape in a similar way as done for the Unity terrain object is not supported though.

    Thanks,
    Raoul
     
  16. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    Hi Raoul, in working assiduously with easy road on my open world project I came up with some connected ideas on real needs that I wanted to bring.

    1) It would be fantastic if the ground polygons could be eliminated even in areas enclosed by roads (where buildings would arise for example) as is already the case for tunnels on the U2019 terrain.

    Eaxample:
    Unity-3d-terrain-tool-open-world-procedural-map.png Easy-road-unity-terrain-tool-world-map.png

    2) Could additional layers of splat maps texture be added to the ground textures? Easy road currently only has one, while three overlapping layers could create white roads without adding the mesh ( Clearly the best effect is obtained based on the resolution of the terrain ).

    Like this:
    Easy-road.unity-3d-dirt-layers.png

    Currently I have to use a separate path tool to do this, but having it integrated on easy road would be fantastic.

    Thanks.
     
  17. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi ciorbyn,

    1) That is v3.3.x, cutting holes in the terrains in these zones is not on the list but the idea is there and it can certainly be added. Currently new triangulation routines are being implemented for v3.3 which is also related to this and v3.2 has the main focus at the moment. But it will be part of the v3.3 alpha / beta at some point.

    2) Yes, that is also on the list in a way. A slightly improved splatmap baking of the road shape in the terrain is already part of the v3.2. More terrain improvements will follow in v3.2.x, like baking the shape in the terrain based on a texture mask, room for 4 terrain texture layers. This is more intended to add variation at the sides of the road mesh, but it should also work for your purpose.

    Thanks,
    Raoul
     
  18. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Are there plans to support authoring road types with a ScriptableObject/.asset based approach? I like to keep my assets in modular packages, so it'd be nice if I can also keep my authored road assets separate from plugin folder structures. I also think it would be more convenient to author road types as separate assets, rather than as part of the colossal EasyRoads menu...
     
  19. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi one_one,

    All road type and side object data in a project is stored in /Assets/EasyRoads3D/Resources/ERSideObjectsLog

    That is also what the road type and side object export options do, but with these options you can select which road types and side objects you want to store. These assets can be used in another project through the road type and side object import options.

    Thanks,
    Raoul
     
  20. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    Great news! Thanks so much.
     
    raoul likes this.
  21. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    So for any time I change the 'exported'/singled out road type, I would need to re-import it, right?
     
  22. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Do you mean change the road type directly in the .asset file? That is not the idea, why would you want to do that?

    The ERSideObjectsLog file I mentioned is updated after road type / side object changes in the open scene. And the same road type / side object in another scene in the same project will be auto updated after selecting the road network object when there are recent changes to that road type / side object in ERSideObjectsLog. Does that help or do you want to do something else?

    Thanks,
    Raoul
     
  23. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    What I mean is that if I change the road type in one project and I would like that change to appear in another project I would need to export and re-import, right?
    Either way, my main goal is that I want to keep authored assets separate from external plugins, for the sake of version control and project management.
     
  24. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Thanks !

    Here's my implementation for anyone else who is using RGSK .

    Edit to add a catch so you don't overwrite your tracks !
    Code (CSharp):
    1.  
    2. using EasyButtons;
    3. using EasyRoads3Dv3;
    4. using RGSK;
    5. using System;
    6. using System.Collections;
    7. using System.Collections.Generic;
    8. using System.Linq;
    9. using UnityEngine;
    10. public class RoadMaker : MonoBehaviour
    11. {
    12.     public TrackLayout trackLayout;
    13.     public ERRoadNetwork roadNetwork;
    14.     public string targetRoadName = "Road1";
    15.     // Uses easy buttons, add this to your package manifest
    16.     //     "com.madsbangh.easybuttons": "https://github.com/madsbangh/EasyButtons.git#upm"
    17.     [Button]
    18.     public void createTrack()
    19.     {
    20.         trackLayout = (TrackLayout)FindObjectOfType(typeof(TrackLayout));
    21.         roadNetwork = new ERRoadNetwork();
    22.         ERRoad road = roadNetwork.GetRoadByName(targetRoadName);
    23.         if (road.GetMarkerCount() != 0)
    24.         {
    25.             Debug.LogWarning("Road has markers , create a new road ");
    26.             return;
    27.         }
    28.         road.AddMarkers(trackLayout.nodes.Select((x) =>
    29.          x.position
    30.        ).ToArray());
    31.     }
    32. }
    33.  
    34.  
     
    Last edited: Jul 22, 2020
    raoul likes this.
  25. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Yes, that can either be done through the export option, but for road types you could also duplicate the ERSideObjectsLog prefab. Then in the other project the road type can be imported through the Import Road Types button. When that road type already exists it will be greyed out and Import is not possible. But this road type can be removed first through "Manage project Road Types" after that it can be imported again and this should work fine with already exisiting roads based on that road type because of the matching ID. You may want to test this workflow to get the idea.

    If you have any suggestions / requests, in v3.3 road type features will be expanded,

    Thanks,
    Raoul
     
  26. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Ah, I see, that sounds like a potential solution.

    Personally, I would think that this sort of data authoring/storage would be a great fit for custom ScriptableObjects, where each road type would have a separate ScriptableObject instance. I think that would also create a better separation between road network authoring and road type authoring.

    Thank you for the quick replies, by the way!
     
  27. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi one_one,

    There is also /Assets/EasyRoads3D/_Preset Editors/Road Types

    This is WIP, especially for v3.3, which has more advanced road type authoring tools like custom shapes. The road type will be visualized. I think this perhaps is more in the direction what you suggested.

    Thanks,
    Raoul
     
    one_one likes this.
  28. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    Hello, how can I import OSM or KML map format? Is there a documentation or tutorial description? Preferably one that combines runtimeAPI!
    My overall requirement is to read such as OSM format and then generate marker points(such as road side object) on the driveway based on runtimeAPI ,Thank you!
     
    Last edited: Jul 24, 2020
  29. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hello yumianhuli1,

    OSM and KML import is supported although crossings are not yet auto generated.

    It is covered here in the manual: https://www.easyroads3d.com/v3/html/general_settings.html#importData

    This feature is currently not part of the scripting API. We can see if it can be added, but this is more intended to be used inside the Unity editor at the moment.

    Thanks,
    Raoul
     
    Last edited: Jul 24, 2020
  30. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Hi Raoul

    Looks like I've ran into this error, when ever I create a new road type with side objects, this happens when I try to place nodes .

    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection
     
  31. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi keithsoulasa,

    That is not standard behaviour so I cannot really give feedback with the current info.

    Which version are you using?

    Are these your own side objects? What type of side objecta are these?

    What happens when deactivating the side objects from this road type, then add a new road of that type, does that work? And if so, what happens when activating these side objects on the specific road afterwards? Does that work or do you get similar errors?

    Thanks,
    Raoul
     
  32. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    Hi, I have another problem with new meshes that I have created. Once converted as procedural crosses, some faces of the mesh receive bad lighting.

    Unity-3d-easy-road-mesh-problem.png unity-easy-road-mesh-face-flipped.png

    how can i solve it?
     
  33. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hi ciorbyn,

    procedural crosses, are these Procedural side objects? Which version are you using? There are no known issues with normals for Procedural side objects in the latest v3.1.9f5 version. Could you send the models so we can test them if you are using this version?

    Thanks,
    Raoul
     
  34. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    No, they are whole meshes of intersections and junctions...

    And I'm using the v3.1.9f5 version.

    easy-road-mesh-joint.png unity 3d-easy-road-procedural-cross-mesh.png

    I'm sending them to you in pvt.
    Thanks
     
    Last edited: Jul 25, 2020
    raoul likes this.
  35. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    I added my own side objects , but it's working now so I'm fine.
     
  36. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Gl
    Glad to hear that! If you have any additional info regarding the error message that was initially thrown, that would be very much appreciated.

    Thanks,
    Raoul
     
  37. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Hello raoul,

    I met a problem,
    In runtime, how should I add sidewalks to all roads? It is possible to add a sidewalk to the intersection in the editor, but is it just a straight road?

    Thanks,
    Zhang
     
  38. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hello Zhang,

    Yes, in v3.1 sidewalks on roads are controlled through the crossing connections they are attached to.

    Do you mean this is a road only with no crossings? In that case sidewalks could be added as side objects like in the HD Roads package.

    Thanks,
    Raoul
     
  39. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Yes,but I have both intersections and straight roads. Which one should I use?

    Thanks,
    Zhang
     

    Attached Files:

  40. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    I am not sure what you mean? In your previous post you asked for sidewalks on a straight road. Alternatively you could connect this road to a crossing with sidewalks, sidewalks will be added to the road, followed by UnConnectEnd() or UnConnectStart(). This will result in a road only with sidewalks.

    Or is this more about adding sidewalks to roads and crossings in general via the scripting API? In that case, please use crossing prefabs with sidewalks already active by default. The roads will update according the sidewalk status on the crossing connection. Just make sure the connection sidewalk status is the same on both the start and end of the road.

    Thanks,
    Raoul
     
  41. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    I know what you mean,thanks!
    I used a crossing that is activated by default on the sidewalk.
    There are two roads. I let the second road be inserted into the first road, so a crossing is generated, but the width does not seem to match correctly.
    I want to make all roads that exist now have sidewalks.Please check the figure1.
    Can you give me some ideas?

    PS: I use runtime api.

    Thanks,
    Zhang
     

    Attached Files:

  42. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Are these roads already connected to a crossing without sidewalks on the other end of the road? The situation I mentioned in the last part of my previous post.

    Thanks,
    Raoul
     
  43. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Thank you for your patience, but I’m sorry I didn’t understand.
    1.Neither road is connected to anything
    2.I use api to separate the first road, insert the connection, and then connect the second road to the 4th interface of the connection.
    3.I want to connect them and add sidewalks, so I can't understand why I use UnConnectStart()

    This is part of my code:
    Code (CSharp):
    1. public void IntersectionRoad(GameObject roadGameObject, ERRoad currentRoad, Vector3 position, int currentMarkerIndex, IntersectionType type)
    2. {
    3.     ERRoad road = _roadNetwork.GetRoadByGameObject(roadGameObject);
    4.     if(road == null)
    5.     {
    6.         Debug.Log("road is null");
    7.         return;
    8.     }
    9.     position = GetNearbyCenterPosition(road, position);
    10.     //int markerIndex = road.InsertMarker(position);
    11.     //road.InsertMarker(position);
    12.     int markerIndex = 1;
    13.     road.InsertMarkerAt(position, 1);
    14.     ERConnection erConnection = _roadNetwork.GetSourceConnectionByName(TcrossName);
    15.     _crossConnection = road.InsertConnector(erConnection, markerIndex, 0, 1, out ERRoad road2);
    16.     road2.gameObject = road2.roadScript.gameObject;
    17.     BuildSlope(road);
    18.     BuildSlope(road2);
    19.     SetConnectionInfo(_crossConnection);
    20.     Connections.Add(_crossConnection.gameObject.name, _crossConnection); //Add this intersection to all intersections
    21.     TC_Generate.instance.autoGenerate = true;
    22.     //If it is on the left, flip it
    23.     Vector3 oldVector = road.GetMarkerPosition(markerIndex) - road.GetMarkerPosition(markerIndex - 1);
    24.     Vector3 currentVector;
    25.     if(type == IntersectionType.In)
    26.     {
    27.         if(currentMarkerIndex == 0)
    28.         {
    29.             currentVector = currentRoad.GetMarkerPosition(1) - position;
    30.         }
    31.         else
    32.         {
    33.             currentVector = currentRoad.GetMarkerPosition(currentMarkerIndex - 1) - position;
    34.         }
    35.     }
    36.     else
    37.     {
    38.         Vector2 currentDir = currentRoad.GetMarkerPosition(1) - currentRoad.GetMarkerPosition(0);
    39.         currentDir.Normalize();
    40.         currentVector = currentDir * 10;
    41.     }
    42.     if((oldVector.x * currentVector.z - currentVector.x * oldVector.z) > 0.0 f)
    43.     {
    44.         _crossConnection.RotateConnections();
    45.     }
    46.     if(type == IntersectionType.In && currentMarkerIndex != 0) currentRoad.ConnectToEnd(_crossConnection, 3);
    47.     else currentRoad.ConnectToStart(_crossConnection, 3);
    48.     _roadNetwork.BuildRoadNetwork();
    49. }
    Thank you very much,
    Zhang
     

    Attached Files:

    Last edited: Jul 27, 2020
  44. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722

    I just tested this with a crossing and 4 roads, all roads start near the crossing so the first marker, index 0, will connect to the crossing.

    Code (csharp):
    1. [MenuItem("EasyRoads3D/Connections/Connect To Start")]
    2.     public static void ConnectToStart()
    3.     {
    4.         ERRoadNetwork network = new ERRoadNetwork();
    5.         ERConnection conn = network.GetConnectionByName("Connection - default road 1155");
    6.         road = EREditor.GetSelectedRoad();
    7.         int index = conn.FindNearestConnectionIndex(road.GetMarkerPosition(0));
    8.         road.ConnectToStart(conn, index);
    9.     }
    10.  
    The results are below.

    On the left the start situation, four roads without sidewalks and the crossing prefab with sidewalks. On the right the results after selecting all four roads one by one and running the above code.

    API-sidewalks.jpg

    Does a similar test work well for you with the specific crossing prefab that you use?

    Thanks,
    Raoul
     
  45. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Hello,raoul.

    Yes,Thank you,I will try again,
    I’m sorry that I have a lot of questions, but I’m building roads during runtime, which is very important to me.
    I am facing a problem and want to know if this situation exists.
    I use runtime api, and there are still two paths.
    When the second path is inserted into the first path, after calling ConnectToStart() to connect to the 4th interface, SideObject disappears on the second road.

    Thanks,
    Zhang
     

    Attached Files:

    • 22.png
      22.png
      File size:
      5.5 KB
      Views:
      336
  46. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Hello Zhang,

    ConnectToStart() involves roads and crossing objects that are already in the scene.

    What exactly are the steps here?

    What I did test was activating a lamppost side object for the road type used in my example code. What I see is that after the line road.ConnectToStart(conn, index); the side objects sometimes disappears. Is that what you mean? I will look into that, but meanwhile please try: road.Refresh(); That will update the full road including side objects.

    Thanks,
    Raoul
     
  47. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Yes,that's what i mean.
    road.Refresh() is a temporary solution?It's work well.

    For unified management, I did not use EasyRoads' default terrain adaptation, but "Terrain Composer".
    I used SideObject to generate an identical "road" on the lower layer of the road for detection, so that the terrain fits the road height.
    When SideObjects fail, the terrain will not adapt to the road height. This is why I take this problem seriously.

    No words can express my gratitude,
    Zhang
     

    Attached Files:

  48. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    I imitated your scene,
    But the result is different,please check the figure.Did i ignore something?

    This is my full code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using EasyRoads3Dv3;
    4. using UnityEngine;
    5. public class SideWalk: MonoBehaviour
    6. {
    7.     private ERConnection _erConnection;
    8.     private ERRoad _road1, _road2, _road3, _road4;
    9.     private List < ERRoad > _roads = new List < ERRoad > ();
    10.     void Start()
    11.     {
    12.         ERRoadNetwork roadNetwork = new ERRoadNetwork();
    13.         _erConnection = roadNetwork.GetConnectionByName("Default X Crossing");
    14.         _road1 = roadNetwork.GetRoadByName("road_01");
    15.         _road2 = roadNetwork.GetRoadByName("road_02");
    16.         _road3 = roadNetwork.GetRoadByName("road_03");
    17.         _road4 = roadNetwork.GetRoadByName("road_04");
    18.         _roads.Add(_road1);
    19.         _roads.Add(_road2);
    20.         _roads.Add(_road3);
    21.         _roads.Add(_road4);
    22.         for(int i = 0; i < _roads.Count; i++)
    23.         {
    24.             int index = _erConnection.FindNearestConnectionIndex(_roads[i].GetMarkerPosition(0));
    25.             _roads[i].ConnectToStart(_erConnection, index);
    26.         }
    27.     }
    28. }
    Thanks,
    Zhang
     

    Attached Files:

  49. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Yes, road.Refresh() is a temporary solution to rebuild the side objects after using ConnectToStart() through the scripting API. Glad to hear that works well.

    Thanks,
    Raoul
     
  50. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    69
    Hi raoul,

    Can you give me some ideas for quesstion #8551?;)

    Thanks,
    Zhang