Search Unity

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,735
    The heighmapscale is about two. It is import to keep this heightmapscale and don't use extreme Pixel Error values on the terrain. That too may effect the results certainly a little bit further from the cam.

    The situation is that the roads are laid out on the terrain, a road mesh is created. When this looks well in the Unity editor and different in Android in a way that the terrain interferes with the road mesh then something must have changed in the Android Build. Do you see the same on builds for other platforms? Have you tried different Android settings?

    Thanks,
    Raoul
     
    Last edited: Jan 22, 2021
  2. denis3510

    denis3510

    Joined:
    May 16, 2020
    Posts:
    10
    Hi, i managed to fix it and its a bit weird that on the unity player its fine and on the mobile its not, But what was cousing this is the "Draw Instanced" setting on the terrain, it was on and after turning this off every thing seems to work and the road is rendering correctly now.

    Again Thank you very much Raoul you saved my day again and now i can keep working on my project ,
    Denis
     
    raoul likes this.
  3. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Thank you for bringing this up to attention! Enabling "Draw Instanced" in the terrain settings indeed can slightly affect the terrain shape.

    Raoul
     
    denis3510 likes this.
  4. rafvasq

    rafvasq

    Joined:
    Feb 6, 2018
    Posts:
    16
    Hi @raoul, I'm interested in the bumpiness functionality. I understand that Road/Segment Smoothness should be my focus. Is it possible to set these values via API?
     
  5. raoul

    raoul

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

    That is possible for the road itself and individual markers in a similar way as in the Inspector. In the ERRoad class:

    Code (csharp):
    1. public void SetRandomBumpiness(float minHeight, float maxHeight, float minDistance, float maxDistance)
    2. public void SetRandomTilting(float minAngle, float maxAngle, float minDistance, float maxDistance)
    3.  
    4. public void SetRandomBumpiness(int markerIndex, float minHeight, float maxHeight, float minDistance, float maxDistance)
    5. public void SetRandomTilting(int markerIndex, float minAngle, float maxAngle, float minDistance, float maxDistance)
    Thanks,
    Raoul
     
    rafvasq likes this.
  6. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    With HDRP is their an easy way to make the road less reflective ? Right now it feels like I'm driving on a mirror
     
  7. raoul

    raoul

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

    What you describe sounds like what happens for some materials in the current HDRP version, those materials that are based on only one road texture. The package will be updated. Meanwhile, it can be fixed by assigning the same textures used for "Main Road" to the "Second Road" slots.

    Thanks,
    Raoul
     
  8. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    As long as it's updated soonish I can wait. I'm using your HD Road pack
     
  9. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    It will be updated this week.

    Thanks,
    Raoul
     
    keithsoulasa likes this.
  10. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Would it be best to delete the whole hd road folder and then import the new package?
     
  11. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Importing updates over the existing import should work well.

    For the main EasyRoads3D Pro package removing the full folder is not recommended as it may have project specific data. Backing up projects before an upgrade is very much recommended.

    Thanks,
    Raoul
     
    keithsoulasa likes this.
  12. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Alternative for ERRoad.GetLength().

    Previously we used GetLength() for our integration with Landscape Builder. This is marked as "obsolete". How can we now get the current length of a road?

    Code (CSharp):
    1. lbRoad = new LBRoad();
    2. erRoad = erRoads[r];
    3.  
    4. if (lbRoad != null && erRoad != null)
    5. {
    6.     // Populate the LBRoad class instance with data from EasyRoads
    7.     lbRoad.roadName = erRoad.GetName();
    8.     lbRoad.roadLength = erRoad.GetLength();
    9.     lbRoad.roadWidth = erRoad.GetWidth();
    10.     erRoadType = erRoad.GetRoadType();
    11.     lbRoad.roadTypeDesc = erRoadType == null ? "unknown" : erRoadType.roadTypeName;
    12.  
    13.     //Debug.Log("[DEBUG] " + lbRoad.roadName + " [" + lbRoad.roadTypeDesc + "]");
    14.  
    15.     // Add the road to the list that will be returned
    16.     roadList.Add(lbRoad);
    17. }
     
  13. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi SD
    Hi Stephen,

    That has been renamed, ERRoad.GetDistance()

    Thanks,
    Raoul
     
  14. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Thanks for the quick reply. Can you recall which version of ER3 this was first introduced? (So we can advise people what's the minimum supported version of ER3 with the next release of LB).
     
  15. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    That was v3.1.9f1

    Thanks,
    Raoul
     
    sstrong likes this.
  16. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Hi, I'm having trouble making a city grid of streets. I have an intersection prefab with sidewalks, so I place that, and can sometimes get the green dot at the edge to appear so I can click-drag to make a new street attached to it. But then it's very tricky to go further -- I want to make another intersection at the end of that new street segment, and can usually do so, but usually the street refused to connect to it, but not always. But even if I can get it to do that, then I can't get a new road to extend out of another side of the intersection. Lots and lots of trial and error, and only occasional success. The tutorial videos make it look so easy, but obviously I'm missing a key step or two. Can you see what it is?



    Also, these intersections are not children of the Road parent, and I can't figure out why.

    And also: How can I smooth out the white lines on the pavement at the intersection?

    Oh, I should have noticed all the errors, but I don't know what they mean:

    NullReferenceException: Object reference not set to an instance of an object
    EasyRoads3Dv3Editor.ODODQCQCOC.OOOQQQDQDO (EasyRoads3Dv3.ERModularBase scr, EasyRoads3Dv3.ERCrossingPrefabs sourceCrossing, UnityEngine.Vector3 pos, UnityEngine.Vector3& OOCDQCOOQC, EasyRoads3Dv3.ERCrossingPrefabs& ODCQDOOOCC, System.Int32& targetElement) (at <9142e9987c6b4868bc1aadd083f8c82f>:0)
    EasyRoads3Dv3Editor.ODODQCQCOC.OOCCOCQCDD (UnityEngine.Vector3 pos, System.Boolean OQDODDQQOD, UnityEngine.Event cEvent, EasyRoads3Dv3.ERModularBase scr, System.Boolean dragStageFlag) (at <9142e9987c6b4868bc1aadd083f8c82f>:0)
    EasyRoads3Dv3Editor.ODODQCQCOC.OnSceneGUI () (at ...

    thanks
    Dave
     
  17. raoul

    raoul

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

    Most of the time the intersections are selected in that state the green connection dots will not be visible.

    Indeed the intersections are not parented to the "Connection Objects" object. That is probably because of the error which may make the behaviour unreliable afterwards.

    I see these are dynamic built-in connections you created. Just as a test, without a road selected, can you select it from the Intersections tab and Shift + Click in the scene to instantiate it. Does that work well without errors? And are the green dots visible after deselecting the intersection?

    If not then perhaps something is wrong with the intersection prefab and the next questions would be, how was it created? Do the provided built-in dynamic crossings work well?

    With regard to the smoothing out the white lines, the corner radius is small which results in the white line markings at the edge not exactly following the corner. This can be fine tuned with the "Inner Segment Distance" control in the Corner Settings.

    Also, a quick way to build this type of city blocks is by using the Grid option in General Settings > Scene Settings. First add all the intersections in one go by simply repeating Shift + Click, they will snap to the grid. Then ther oads can be created quickly by pulling them out from one connection and instantly snapping it to the connection on the other end. The easiest workflow is first set the grid build the roads and then add the buildings but in your case this should also work, the grid size and rotation is adjustable.

    Thanks,
    Raoul
     
  18. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks for the tips. I reimported the whole package and that eliminated the errors, so somehow I must have messed something up. So now it's working better, though sometimes a road segment still refuses to snap to an intersection.

    Two other questions:

    1) I have a city intersection with Uniform Opposite Connections, and the white lines don't meet up, see screenshot. Anything I can do about that?

    2) Quite often, the Sidewalks subsection of the intersection panel is dimmed and inactive. I've got a vague idea that this is derived from the selected road type, but I've got sidewalks enabled on my City Street road type (well, I did that initially, but now I can't even find where to view/edit that on raods), but still, usually, sidewalks are inactive and disabled on the intersection.I know that the problem is that I simply don't understand the whole tool well enough, but....any tips?

    thanks
    Dave
    intersection lines.JPG
     
  19. raoul

    raoul

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

    Glad to hear this is working better now. In what way do road markers sometimes not snap? Are the green handles not visible, do the handles appear in red?

    1) It looks like the same road material / texture is used on roads with different widths. That will result in what is visible in the image. When the road width is smaller, the white lines should be closer to the edge. In v3.3, available in alpha builds on our website, more road type options are available. For instance the profile of the texture can be set, that way the same texture material can be used on roads with different widths, though this will affect triangle count.

    2) The actual active state of sidewalks when instantiated in the scene does depend on the status of sidewalks on roads and how intersections are added. If the sidewalk status is active then Shift + Click in the scene with no road selected will instantiate the intersection with the sidewalks. When the intersection is added to the scene with a road selected, the intesrection will snap to this road with sidewalks inactive regardless the sidewalk active state for this prefab in the project folder. But the "Sidewalk" option is available in the Inspector after selecting the intersection and sidewalks can also be activated per corner by clicking these grey corner handles.

    Thanks,
    Raoul
     
  20. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks, but not sure what to do. Are you saying I need to get the alpha in order to fix these intersections where the white lines don't connect? (I tried creating a new road type but unclear on if/how to make that fix the problem.)

    Also: when an intersection has two different types of roads, the junction between those textures is pretty crude. I don't mind the straight edge, but it would be much more natural for that to be at the edge of the intersection rather than across the middle of it, diagonally. Is there a way to make it do that?

    thanks
    Dave
     

    Attached Files:

  21. raoul

    raoul

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

    First of all just to confirm, do the roads indeed have different widths? Using the same texture / material will have the result seen in your image. There is no way around that. So in v3.1 a different texture must be used for one of these two roads. Alternatively a crossing texture with no line markings at all can be used.

    I mentioned v3.3, just to say that there will be more options to deal with this in future versions. The v3.3 alpha is available on our website.

    The other texture question is also a limitation in v3.1. One way to deal with this in v3.1 is the custom connection system. It is possible to import your own crossing models, also crossings with different roads types.

    But also regarding this v3.3 will have improvements. The Flex Connector in v3.3 supports both flexible angles between connected roads and the triangulation supports different road types.

    flex.jpg

    Thanks,
    Raoul
     
  22. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Wow, 3.3 looks great. So if I do cruder intersections now, will it be easy to convert them once 3.3 is further along?
     
  23. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Yes, but there is one important requirement. The Flex Connector, used in the Image in my previous post, is purely road type based. It will be very easy to create intersections and new roads this way, https://easyroads3d.com/v3alpha.php. So to convert the current built-in X and T Crossings to a Flex Connector it is important to create the roads based on road types.

    In the current alpha, v3.1 X and T Crossings can be selected, a checkbox "Flex Connector" will be visible. This will turn the intersection into a Flex Connector. So yes, current X and T Crossings can be converted into a Flex Connector. One way or another it will be possible to automate this process in the final v3.3 for all intersections or perhaps for specific intersection types.

    Thanks,
    Raoul
     
  24. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    Hi Raoul,

    Im currently working on runtime road editor using the easy roads v3 asset. I'm looking for a way to create sideobjects such as walls/sidewalks along the roads. Do you have any suggestions on how to add those runtime?

    In the api documentation I see methods such as SetSideObjectOffset, but no create methods.

    Kind regards,
    Roy
     
  25. raoul

    raoul

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

    Are you creating the road network at runtime? For side objects, and also easier for road types, please use a road network object that already exists in the scene. That way both road types and side objects can be added to the road network object ready to use at runtime. In this setup the same road network constructor can be used in your script, it will create a reference to the road network object in the scene.

    Then to get the side object in the ERRoadNetwork class:

    public SideObject GetSideObjectByName(string name)

    And to activate this side object on a road and on road marker(s) in the ERRoad class:

    public void SideObjectSetActive(SideObject obj, bool value)
    public void SideObjectMarkerSetActive(SideObject obj, int markerIndex, bool value)
    public void SideObjectMarkerSetActive(SideObject obj, int[] markerIndexes, bool value)

    These steps should be all, could you try that?

    Thanks,
    Raoul
     
  26. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    Thank you for your quick response,

    I currently use a road network that is created at runtime. I'll see if I can get it to work with your method :)
     
    raoul likes this.
  27. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    public SideObject GetSideObjectByName(string name)
    returns a SideObject but when I try to use that SideObject in
    public void SideObjectSetActive(SideObject obj, bool value)
    or
    public void SideObjectMarkerSetActive(SideObject obj, int markerIndex, bool value)
    nothing happens :/

    Do you have any idea what might cause this?

    The code I used(I simplified it a bit):

    RoadModel = RoadNetwork.CreateRoad("road " + id, roadType, markers);

    SideObject sideObject= RoadNetwork.GetSideObjectByName(sideObjectName);
    RoadModel.SideObjectSetActive(sideObject, true);
     
    Last edited: Feb 2, 2021
  28. Spellarena

    Spellarena

    Joined:
    Dec 23, 2020
    Posts:
    1
    Hi Raoul,

    I'm using EasyRoads3D Pro v3.1.9f6 also Unity 2020.1.17 and I have a problem with the flex connector, it's simply not visible when selecting crossing. In comparsion with older versions there was the checkbox which you could control it with. I've tried looking for info but i had not found much if anything changed. Could you explain me step by step how it works now? That is the kind of crossing that i want to get.

    Kind regards,
    DS
     

    Attached Files:

  29. raoul

    raoul

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

    The Flex Connector is v3.3 which is available in alpha builds on our website. You may have seen a video on this page https://easyroads3d.com/v3alpha.php ?

    Thanks,
    Raoul
     
    Spellarena likes this.
  30. Sk4tOoR

    Sk4tOoR

    Joined:
    Sep 19, 2018
    Posts:
    14
    Hello,

    I'm running into issues while building terrains. I've build a medium large road (1500 meters) connected with IConnectors and several custom sideObjects. It is a mutli scene and multi terrain setup. So the roadNetwork and the terrains are stored in different scenes. I'm using EasyRoads Version 3.1.9f6. I jumped back to this version meanwhile because newer versions produced the same bug.

    I've tried to disable all the settings for build terrain ('Update Hightmap' and so on). With all settings disabled the terrain won't build. Selecting a single terrain to build dosen't solve the problem as well. But 'Select Roads Only' is working properly. Any ideas how to fix this?

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. EasyRoads3Dv3.QDQDOOQQOOQDD.ODDOOCOCQO (EasyRoads3Dv3.ERModularBase scr, System.Single& minx, System.Single& minz, System.Single& maxx, System.Single& maxz, System.Single splatmapScale) (at <057bff3f3def4743922a47fc935356c1>:0)
    3. EasyRoads3Dv3Editor.OQCODCQDQQ.OQOOCOQOQQ (EasyRoads3Dv3.ERModularBase scr, EasyRoads3Dv3Editor.OQOQDCQQQD eScr) (at <7e0a4c811c5f4cbdae4311d2f3a36962>:0)
    4. EasyRoads3Dv3Editor.OQOQDCQQQD.OnInspectorGUI () (at <7e0a4c811c5f4cbdae4311d2f3a36962>:0)
    5. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <701f6580abad44cfb237a543dcd0d94b>:0)
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    Thank you
     
  31. raoul

    raoul

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

    The error is indeed raised in the part that updates the terrain.


    What exactly do you mean with this? What is the exact workflow up to the point where you want to swirch to Build Mode? How is the mulkti scene setup involved in this?

    In that case, is a specific road causing the problem. How large is the road network? Can the issue be isolated by building batches of selected roads? Have you tried the "Refresh Road Network" option near the bottom in general Settings? Since there is an issue, you may want to backup the project first.

    Thanks,
    Raoul
     
  32. Sk4tOoR

    Sk4tOoR

    Joined:
    Sep 19, 2018
    Posts:
    14
    Thanks for the fast reply :)

    "So the roadNetwork and the terrains are stored in different scenes."

    It simply means in my project the road netwerk is placed in scene A and the terrains are in scene B. I think the error occurs after closing the project and opening it againing, loading scene B additive to scene A.

    Refresh Road Network give following Debug Message:

    Code (CSharp):
    1. EasyRoads3Dv3 Warning: Unable to find road network script, please report. Are you using deeply nested connection prefabs?
    2. UnityEngine.Debug:Log(Object)
    3. EasyRoads3Dv3.ERModularRoad:OOOQDDDDCC(Boolean, Boolean)
    4. EasyRoads3Dv3Editor.OQCODCQDQQ:OQDQDQDQDQ(ERModularBase)
    5. EasyRoads3Dv3Editor.OQCCQQQOOC:ODQOOOQCCD(ERModularBase, OQOQDCQQQD)
    6. EasyRoads3Dv3Editor.OQOQDCQQQD:OnInspectorGUI()
    7. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean
    I too use deply nested connection prefabs, but this prefabs are finalized roads without any EasyRoads script attached. I don't use this prefabs to add connections in an existing roadNetwork. They are just for duplicated placment in different scenes.
     
  33. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    The warning indicates that the road network setup is not as expected. What does your hierarchy look like? Where is the road network object located and are all road objects located under the "Road Objects" game object? In any case this is just a warning pointing to a specific road, it is not critical by itself, but it means the road will not be created. So something seems not quite right in this scene.

    Have you tried another "Refresh Road Network"? Because road objects in the above situation with no actual markers / road meshes will be removed in the "Refresh Road Network" process. Does this warning still appear after another Refresh Road Network"? And if not, does switching to Build Mode still not work?

    Thanks,
    Raoul
     
  34. Sk4tOoR

    Sk4tOoR

    Joined:
    Sep 19, 2018
    Posts:
    14
    Finally I found some Prefabs were EasyRoads scripts were attached. Removing the scripts solved the problem! Finally I solved this problem, thank you alot!
     
    raoul likes this.
  35. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    Hi Raoul,

    I tried your method of creating the ERRoadNetwork in the scene and using that to add the side objects but I'm having some problems getting it to work.

    public SideObject GetSideObjectByName(string name)
    returns a SideObject but when I try to use that SideObject in
    public void SideObjectSetActive(SideObject obj, bool value)
    or
    public void SideObjectMarkerSetActive(SideObject obj, int markerIndex, bool value)
    nothing happens :/

    Do you have any idea what might cause this?


    The code I used(I simplified it a bit):

    RoadModel = RoadNetwork.CreateRoad("road " + id, roadType, markers);

    SideObject sideObject= RoadNetwork.GetSideObjectByName(sideObjectName);
    RoadModel.SideObjectSetActive(sideObject, true);
     
  36. raoul

    raoul

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

    The provided code creates a road and activates a side object. What type of side object is that? What is the status of "Default active state for each marker" for this side object. If this is not toggled on then it must be activated for specific markers before it will be come visible.

    Thanks,
    Raoul
     
  37. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Any update on this
     
  38. raoul

    raoul

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

    The package is updated and will be submitted today or tomorrow. The fix as suggested should work.

    Thanks,
    Raoul
     
    keithsoulasa likes this.
  39. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Is this somewhat automatic or do I need to do something else aside from just updating it
     
  40. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    keithsoulasa likes this.
  41. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    I used the Concrete Barrier Simple Left from the demo scene.
    It has default active state for each marker set to true.
    I also tried to manually set each marker with SideObjectMarkerSetActive(sideObject, markers, true);
    but that doesn't work either :/

    Thanks again for the quick response, I hope we can find a solution.

    Roy
     
  42. raoul

    raoul

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

    Can you post the exact code snippet? Or did you test the code you posted here.

    How is this used? Inside the Unity editor in editor scripts or at runtime? Is it possible to test the code? Are there errors at anytime?

    Thanks,
    Raoul
     
  43. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    Hi Raoul,
    It is the code I posted above. I use it at runtime. I do not get any error messages :/
    GetSideObject returns a SideObject but I cannot seem to attach it to the road at runtime.
     
  44. raoul

    raoul

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

    You mentioned that example is simplified, that is why I was asking. This is code related so we need to know the exact situation on your end.

    And since this is also runtime related, which version are you using? Is it the latest v3.1.9f6? Or could you otherwise try the v3.2 beta in /Assets/EasyRoads3D/Beta Release/?

    Thanks,
    Raoul
     
  45. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    updating to the v3.2 did not change anything unfortunately.

    I did some more testing. SideObjectSetActive() does work on a road that is made in the editor but not on the one generated runtime.

    code:

    Code (CSharp):
    1. using EasyRoads3Dv3;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class SideObjectTest : MonoBehaviour
    7. {
    8.     public ERRoadNetwork roadNetwork;
    9.     public ERRoad road;
    10.     public GameObject roadGO;
    11.     public string sideObjectName = "Concrete Barrier Simple Left";
    12.     public bool sideObjectActive;
    13.     void Awake()
    14.     {
    15.         roadNetwork = new ERRoadNetwork();
    16.     }
    17.  
    18.     private void Start()
    19.     {
    20.         ERRoadType roadType = new ERRoadType();
    21.         roadType.roadWidth = 6;
    22.         roadType.roadMaterial = Resources.Load("Materials/roads/road material") as Material;
    23.         Vector3[] markers = new Vector3[4];
    24.         markers[0] = new Vector3(200, 5, 200);
    25.         markers[1] = new Vector3(250, 5, 200);
    26.         markers[2] = new Vector3(250, 5, 250);
    27.         markers[3] = new Vector3(300, 5, 250);
    28.  
    29.         road = roadNetwork.CreateRoad("road 1", roadType, markers);
    30.  
    31.     }
    32.     private void Update()
    33.     {
    34.         if (Input.GetKeyDown("space"))
    35.         {
    36.             ToggleBarrier();
    37.         }
    38.     }
    39.     void ToggleBarrier()
    40.     {
    41.         SideObject sideObject = roadNetwork.GetSideObjectByName(sideObjectName);
    42.         sideObjectActive = !sideObjectActive;
    43.  
    44.         road.SideObjectSetActive(sideObject, sideObjectActive);
    45.     }
    46. }
     
  46. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735

    Hi Roy,

    It appears that side objects at runtime require an already existing road type to be assigned. Instead of creating the road type at runtime, at line 20, can you try something like this (assuming you have all demo package road types imported in the road network object):

    ERRoadType roadType = roadNetwork.GetRoadTypeByName("Primary Road");

    On our end the side object is generated, also in v3.1.9f6.

    I will check why this does not work when the road type is created at runtime.

    Thanks,
    Raoul
     
  47. RoyInfranea

    RoyInfranea

    Joined:
    Jan 11, 2021
    Posts:
    8
    Thanks! that is it :D
     
    raoul likes this.
  48. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Glad to hear that! That is why I asked for code, it usually makes it easier to debug the situation :)

    Thanks,
    Raoul
     
  49. GamesDeveloper_01

    GamesDeveloper_01

    Joined:
    Dec 16, 2020
    Posts:
    1
    Hi Raoul,

    I was wondering if it is possible to create a smooth connection between wide(30) and narrow(15) roads but connected like this. I've tried flex connecting this but it doesnt join smoothly as it should do. What would you suggest as the creator?

    upload_2021-2-5_13-47-57.png

    Thanks in advance,
    Kate
     
  50. raoul

    raoul

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

    This is a very specific shape. What does the road material look like?

    The shape can be recreated to some extend with a single road using the Circular Control type for the turn. Then either the scale can be adjusted, the left road. or the shape can be adjust by activating node handles and moving the outer node towards the center. The second option allows a smaller radius without the shape becoming distorted.

    circular2.jpg

    Both options will result in the material being squeezed.

    Another option is by modeling the turn. That way it can be made exactly how you want it to be. The model can be imported into the system as a custom connection prefab, https://easyroads3d.com/tutorials/custom_crossings.php. It will interact with roads just like built-in connection prefabs.


    Thanks,
    Raoul