Search Unity

Road Architect: Roads, intersections and bridges for Unity [RELEASED]

Discussion in 'Assets and Asset Store' started by MicroGSD, Mar 5, 2014.

  1. sharkapps

    sharkapps

    Joined:
    Apr 4, 2016
    Posts:
    145
    thanks for the report, @jdm4344, i will post an update. i will also include that change in the updated .unitypackage when it is ready.
     
    jdm4344 likes this.
  2. dsm350

    dsm350

    Joined:
    Jun 27, 2018
    Posts:
    2
    Hello guys..not sure anyone is still active here but I will give it a try..Im using Unity 2018 and road architect works just fine..the only thing I like to know is how to use the tunnels..If I used like making a bridge or just apply between 2 notes it will cut mine mountain in two..any suggestion??
     
  3. Boneyard_Games

    Boneyard_Games

    Joined:
    Jul 12, 2013
    Posts:
    4
    I've done something similar. You'll need to use an asset that can create a hole in your terrain, I cant remember the exact one I've used, but you'll need something like this: https://assetstore.unity.com/packages/tools/terrain/microsplat-terrain-holes-97495

    Good Luck
     
    Last edited: Nov 9, 2018
    JBR-games likes this.
  4. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    395
    @dsm350 Create your mountain in a modelling package like Blender (free). Now you can put holes in it where ever your heart desires. Alternatively, just model the top half of the mountain and place it onto the terrain on top of your tunnel.

    Mark
     
    sharkapps likes this.
  5. Ithil-Faroth

    Ithil-Faroth

    Joined:
    May 31, 2018
    Posts:
    2
    Hello,
    I am having a problem with creating a new road.
    I create a terrain and then create the road network and then I click add road.
    When I click ctrl + click instead of placing a marker the terrain is selected.
    Am I missing something?
    Thanks,
    Tom
     
  6. Ithil-Faroth

    Ithil-Faroth

    Joined:
    May 31, 2018
    Posts:
    2
    I have resolved this problem. It was a problem with my custom layout. I just used unity's already existing layout. I don't know the cause but it is not related to Road Architect.
    Sorry for the inconvenience
     
    JBR-games likes this.
  7. dsm350

    dsm350

    Joined:
    Jun 27, 2018
    Posts:
    2
    Thanks Texmax and Mark..I have another question. how to connect one road to each other..like a circle for race track?
     
  8. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    174
    Has anyone managed to create highway ramps connections using road architect? I really love how intuitive this asset is, and it's so sad it's not supported anymore. The only thing missing for me to use it in our project is to have ramps :(
     
  9. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    174
    Anyone is having the problem where the terrain is affected by Road Architect but doesn't revert the terrain to its original state when moving nodes?
     
  10. Hypester

    Hypester

    Joined:
    Jan 23, 2018
    Posts:
    17
    Newbie question here, I put the RoadArchitect-Master folder into my assets folder and Unity seems to have imported it, but the Road Architect option doesn't appear in the menu, even if I shut down and restart Unity. Is there anything basic I've overlooked?
     
  11. embeddedt

    embeddedt

    Joined:
    Mar 10, 2018
    Posts:
    32
    @Hypester It needs to be called just RoadArchitect and not RoadArchitect-master.

    Also, what Unity version are you using?
     
  12. embeddedt

    embeddedt

    Joined:
    Mar 10, 2018
    Posts:
    32
    Ramps are not supported in my fork (not sure about FritzsHero's fork, https://github.com/FritzsHero/RoadArchitect).

    That is a general problem with RoadArchitect. It forgets about terrain state under certain conditions. Probably won't be fixed in the short term unless interest develops.
     
  13. FN_ord

    FN_ord

    Joined:
    Feb 27, 2018
    Posts:
    5
    Hello, i am trying to insert group objects dynamically (namely, GSDGroup-KRailLights-6L and GSDGroup-Fancy1-6L) to a continuous road generated in runtime, and cannot find a clear way to do this through code. I have browsed the road automation script and tried loading these objects directly upon programmatic node creation with:

    tNode.LoadWizardObjectsFromLibrary("W/GSDGroup-Fancy1-6L", false, false);


    on the method:

    public static GSDSplineN CreateNode_Programmatically(GSDRoad tRoad, Vector3 NodeLocation)


    It seems far too simplistic and sure enough it fails. Could you shed some light on this, please?
     
  14. embeddedt

    embeddedt

    Joined:
    Mar 10, 2018
    Posts:
    32
    First of all, I'm curious how you were able to do that! I didn't know it was possible to create a road at runtime when not running inside the Unity editor, as the road creation APIs are not available in a built game.

    Try loading them once you have three nodes. Loading those objects on a single node won't work very well.
     
    FN_ord likes this.
  15. FN_ord

    FN_ord

    Joined:
    Feb 27, 2018
    Posts:
    5
    Thanks for the response. I've really dived in and the whole project is amazingly complex. For this idea I've just followed along the lines of the GSDRoadAutomation.cs and the GSDUnitTests.cs. The key point was finding out that it had to run on single thread (by default RoadArchitect runs multithreaded). Here's the quick example to check if it's working:

    Code (CSharp):
    1. public class InsertRoad : MonoBehaviour
    2. {
    3.     private GSDRoadSystem roadSystem;
    4.     private GSDRoad road;
    5.  
    6.     void Start()
    7.     {
    8.         CreateNewRoadSystem();
    9.  
    10.         List<Vector3> nodeList = new List<Vector3>();
    11.         Vector3 v1 = new Vector3(500, 0, 0);
    12.         nodeList.Add(v1);
    13.         Vector3 v2 = new Vector3(500, 0, 1000);
    14.         nodeList.Add(v2);
    15.  
    16.         InsertNewRoadSegment(nodeList);
    17.     }
    18.  
    19.     private void InsertNewRoadSegment(List<Vector3> nodeList)
    20.     {
    21.         roadSystem.opt_bAllowRoadUpdates = false;
    22.         foreach (Vector3 node in nodeList)
    23.         {
    24.             GSDSplineN f = GSDRoadAutomation.CreateNode_Programmatically(road, node);
    25.         }
    26.         roadSystem.opt_bAllowRoadUpdates = true;
    27.         roadSystem.UpdateAllRoads();
    28.     }
    29.  
    30.     private void CreateNewRoadSystem()
    31.     {
    32.         GameObject tRoadSystemObj = new GameObject("RoadArchitectSystem");
    33.         roadSystem = tRoadSystemObj.AddComponent<GSDRoadSystem>();
    34.         roadSystem.opt_bAllowRoadUpdates = false;
    35.         roadSystem.opt_bMultithreading = false; // This is key for runtime generation
    36.  
    37.         List<Vector3> empty = new List<Vector3>() { };
    38.         road = GSDRoadAutomation.CreateRoad_Programmatically(roadSystem, ref empty);
    39.  
    40.         road.opt_bIsLightmapped = true;
    41.         road.opt_bIsStatic = true;
    42.         road.opt_Lanes = 6;
    43.         road.opt_ClearDetailsDistance = 36;
    44.         road.RoadMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDShoulder1.mat");
    45.  
    46.         roadSystem.opt_bAllowRoadUpdates = true;
    47.         roadSystem.UpdateAllRoads();
    48.     }
    49. }
    The highway group object is really awesome and it's worth the hassle. I will test again, as i think you are correct, i'm trying to load the group object right off from the first node generated:

    Code (CSharp):
    1. public static GSDSplineN CreateNode_Programmatically(GSDRoad tRoad, Vector3 NodeLocation)
    2.         {
    3.             int SplineChildCount = tRoad.GSDSpline.transform.childCount;
    4.             GameObject tNodeObj = new GameObject("Node" + (SplineChildCount + 1).ToString());
    5.             GSDSplineN tNode = tNodeObj.AddComponent<GSDSplineN>(); //Add the node component.
    6.          
    7.             if (NodeLocation.y < 0.03f)
    8.             {
    9.                 NodeLocation.y = 0.03f;
    10.             }
    11.             tNodeObj.transform.position = NodeLocation;
    12.  
    13.             tNodeObj.transform.parent = tRoad.GSDSplineObj.transform;
    14.  
    15.             tNode.idOnSpline = (SplineChildCount + 1);
    16.             tNode.GSDSpline = tRoad.GSDSpline;
    17.  
    18.             //tNode.LoadWizardObjectsFromLibrary("W/GSDGroup-Fancy1-6L", false, false);
    19.             tNode.LoadWizardObjectsFromLibrary("W/GSDGroup-KRailLights-6L", false, false);
    20.             //tNode.LoadWizardObjectsFromLibrary("W/GSDGroup-Rumblestrips-6L", false, false);
    21.             //tNode.LoadWizardObjectsFromLibrary("W/GSDGroup-WBeamLeftTurn-6L", false, false);
    22.  
    23.             tRoad.UpdateRoad();
    24.  
    25.             return tNode;
    26.         }
     
  16. embeddedt

    embeddedt

    Joined:
    Mar 10, 2018
    Posts:
    32
    One suggestion: before you dive in too far, I suggest that, if you aren't already, use my fork instead of the official repository (link below). My fork has several bugfixes applied by me and FritzsHero.
     
    FN_ord and hopeful like this.
  17. FN_ord

    FN_ord

    Joined:
    Feb 27, 2018
    Posts:
    5
    Yes, thanks. I did went for your fork after this. And after dozens of prints everywhere... I think I found a solution! In fact, programmatically only after a call for
    GSDRoadSystem.UpdateAllRoads()
    is the road actually created along with its base objects. Until then we've just set the nodes. In Unity editor this is automatic but not when done in code. So, to insert other custom objects there should be a second iteration over the nodes, after the road has been created. For anyone who wants to test it, don't lose sight of the GSDRoadAutomation.cs and setup a empty game object with some variation on this script. Note: This means it's possible to create and customize a road/bridge/etc with all of RoadArchitect objects just in code and on runtime, either adding segment after segment with some kind of trigger (which i found to be rather too expensive in terms of framerate) or at runtime start receiving distance parameters and random node positions for example.

    Code (CSharp):
    1. using GSD.Roads;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class InsertRoad : MonoBehaviour
    6. {
    7.     private GSDRoadSystem roadSystem;
    8.     private GSDRoad road;
    9.  
    10.     void Start()
    11.     {
    12.         List<Vector3> nodeList = new List<Vector3>();
    13.  
    14.         Vector3 v1 = new Vector3(0, 0, 0);
    15.         nodeList.Add(v1);
    16.         Vector3 v2 = new Vector3(0, 0, 1000);
    17.         nodeList.Add(v2);
    18.  
    19.         CreateNewRoadSystem(nodeList);
    20.     }
    21.  
    22.     private void CreateNewRoadSystem(List<Vector3> nodeList)
    23.     {
    24.         GameObject tRoadSystemObj = new GameObject("RoadArchitectSystem");
    25.         roadSystem = tRoadSystemObj.AddComponent<GSDRoadSystem>();
    26.         roadSystem.opt_bAllowRoadUpdates = false;
    27.         roadSystem.opt_bMultithreading = false; // This is key for runtime generation
    28.  
    29.         road = GSDRoadAutomation.CreateRoad_Programmatically(roadSystem, ref nodeList);
    30.  
    31.         for (int i = 0; i < road.GSDSpline.mNodes.Count - 1; i++)
    32.         {
    33.             road.GSDSpline.mNodes[i].LoadWizardObjectsFromLibrary("GSDGroup-KRailLights-6L", true, false);
    34.             road.GSDSpline.mNodes[i].LoadWizardObjectsFromLibrary("GSDGroup-Fancy1-6L", true, false);
    35.         }
    36.  
    37.         road.opt_bIsLightmapped = true; // These are just a quick way to edit the road
    38.         road.opt_bIsStatic = true;
    39.         road.opt_Lanes = 6;
    40.         road.opt_ClearDetailsDistance = 36;
    41.  
    42.         roadSystem.opt_bAllowRoadUpdates = true;
    43.         roadSystem.UpdateAllRoads();
    44.     }
    45. }
     
  18. embeddedt

    embeddedt

    Joined:
    Mar 10, 2018
    Posts:
    32
    I hope you are not planning to build this into a standalone Unity game. As far as I know, the road creation code can only be used by scripts when they are running in the editor.
     
  19. FN_ord

    FN_ord

    Joined:
    Feb 27, 2018
    Posts:
    5
    Thanks for the heads-up @embeddedt. I've made a few tries on building a standalone and it actually looks feasible, although it involves disabling or replacing all of the UnityEditor API calls and loading resources carefully (as of right now a test version manages to generate road with some objects but not every material/texture is being loaded properly). From what I read,
    Resources.Load<T>
    should work on a windows build, replacing
    UnityEditor.AssetDatabase.LoadAssetAtPath
    (...and it's loading fine in Unity). I'll keep trying.
     
  20. embeddedt

    embeddedt

    Joined:
    Mar 10, 2018
    Posts:
    32
    Let me know if you need any assistance. I'd be interested in these changes if you are willing to contribute them.
     
    hopeful likes this.
  21. ajith_sreenivasan

    ajith_sreenivasan

    Joined:
    Aug 29, 2018
    Posts:
    4
    shadows are not displaying on the road
     
  22. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,035
    A few people mentioned they were having a hard time getting Road Architect setup in Unity, here's a getting started tutorial.

     
    TerraUnity and chrisk like this.
unityunity