Search Unity

EasyRoads3D v3 - the upcoming new road system

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

  1. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Thank you for the feedback!

    Raoul
     
  2. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    This was brought up a couple of weeks ago and should actually work in v3.1.5. I just tested this on X Position in the dev project and it does update after pressing "Update Scene Instances". Not in the the final 2018.3 build though. I will look into this too.

    Thanks,
    Raoul
     
  3. swnc

    swnc

    Joined:
    Aug 3, 2018
    Posts:
    27
    Hi Raoul,

    I am trying to split a road in the middle and attach T- crossing between them via scripting API. However, I have realized that I can not attach a crossing to start of the split road segments. The crossing is always attached to the end. The code on the below is for testing but if you try you will see that crossing is always attached to the end.

    Code (CSharp):
    1.  
    2. ERConnection sourceConnection = roadNetwork.GetSourceConnectionByName("Default T Crossing");
    3.  
    4.         ERConnection connection;
    5.         ERRoad road2 = road.InsertIConnector(3, "connection name", out connection);
    6.  
    7.         road.UnConnectEnd();
    8.         road.UnConnectStart();
    9.         road2.UnConnectStart();
    10.         road2.UnConnectEnd();
    11.  
    12.         Destroy(connection.gameObject);
    13.  
    14.         road2.AttachToStart(sourceConnection, 0);
    Am I doing something wrong?
    ps: version is v3.1.5

    Best,
    swnc
     
  4. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi swnc,

    I just tested the road2.AttachToStart(sourceConnection, 0); part. The same happens on our end. This is fixed in the next update.

    Unless you want to pass another connection index then 0, the below works well and will have the same result.

    road2.AttachToStart(sourceConnection);

    Thanks,
    Raoul
     
  5. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    @Izanamya, this is fixed in the next update. Thank you for reporting this!

    Raoul


    .
     
    hopeful likes this.
  6. StrategyTron

    StrategyTron

    Joined:
    Feb 20, 2019
    Posts:
    12
    I saw that this tool can be used at runtime.

    Does this mean I can actually make a tool for the player to build roads, like in a city building game?
    Has anyone done this or something like it before?
     
  7. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi chase842,

    v3 includes a scripting API that can be used at runtime. Not all Unity editor functionality is available yet but both roads and crossings can be created in a similar way as in the Unity editor, with Edit and Build mode status. No interface is provided at the moment, you will have to create that.

    Thanks,
    Raoul
     
  8. StrategyTron

    StrategyTron

    Joined:
    Feb 20, 2019
    Posts:
    12
    Oh, my, god!

    I was about to give up on making a road system like yours for run time, and just switch the entire design of my city building game to be grid based. I have no problem designing my own interface and buttons.

    I saw that some of the documentation of the API is empty.
    http://unityterraintools.com/EasyRoads3D/v3/html/EREditor.html

    So, the tool can be used at run-time, that's awesome! I do need to make sure, because of the needs of my game with this tool.
    Does the run-time API functionality include adjusting the road to the slop of the terrain seamlessly, and to adjust the height of the terrain to the road as well, like it does in my project(not run-time)?

    Is there a way I can test this out before I make the purchase? I am making my first game, and I am on a tight budget, spending my personal money and all, as many of us end up having to do.

    A video tutorial may be a smarter way to go about this, that way you don't have to take a risk by share any proprietary assets for testing, and if anyone else asks, you can just point them to that video!

    I'd be happy to purchase it after I can make sure it suits my need.

    If you wouldn't also mind, it would also be great if you could cover 2 other things in a video(s):
    - The waypoints that are generated and show an example of how to integrate them into an existing network of nodes, and still get cars to look believable when they are turning.

    - How one could use collision(other other type of) detection to place a building at the edge of the road. I saw how the mesh for the roads really scales/flairs outwards, and I am already predicting it will cause some issues with building placement detection for my game.

    Amazing asset! Basically saved a few game mechanics from my game from being scrapped!
    Thank you!
     
    Last edited: Feb 22, 2019
  9. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi chase842,

    The EREditor class is currently limited to getting the ERRoad reference from the selected road in the scene. This can be useful when using the scripting API inside the Unity editor, but it is of no use at runtime.

    Are you referring to the "Follow terrain Contours" option? That is currently not part of the scripting API yet. The height of the terrain can be adjusted to the road shapes similar as inside the Unity editor. The scripting API, BuildRoadNetwork() and RestoreRoadNetwork() to switch back to Edit Mode.

    There is a free version but it does not include the scripting API. Unfortunately the Unity asset store does not support trial versions.

    The package includes a simple runtime scene where are road is created and afterwards an object follows the road. Creating roads takes max 3 lines of code. Crossings can be added with one line of code, crossings can be removed, repositioned etc. The same for roads and road markers.


    I am not sure about this question? And turning cars... this tool does not include a full traffic system. In v3.2 this will be improved with options to define lane info and generatin glane data. The v3.2 beta also includes a simple AI script using this data.

    You will need straight road sections if you want static box type of buildings at the exact edge of the road. There are no scripts for edge collision detection. The side objects system can position objects at the exact edge of the road and aligned with the road. Other users have posted links here to projects also involving placing buildings.

    Thanks,
    Raoul
     
  10. StrategyTron

    StrategyTron

    Joined:
    Feb 20, 2019
    Posts:
    12
    Raoul,

    Thank you for the quick and informative replies!

    That sounds like the right thing I was looking for. I saw in one of the videos a functionality that, well, made the roads "Follow terrain Contours", but I did not see any options for the roads to do that in the demo.

    This would be an absolute must for a run-time tool, so the player in my game can make roads.

    This is a feature I am more flexible on. I can either find a way to write my own script to figure a way out, if possible, to make my own edge collision detection for building placement, or just restrict the player to being able to place buildings at certain angles.


    Are there any plans on adding "Follow terrain Contours" to the run-time scripting API, so we can make in-game road creation that follows the terrain?

    Also, I have never considered it, but is there a way to write or modify scripts for a plugin you purchased, to try and add in run-time functionality for something like "Follow terrain Contours"? If yes, is that against licensing?
     
    Last edited: Feb 22, 2019
  11. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi chase842,

    Marker control points can be snapped to the terrain making the roads already follow the terrain and by placing marker control points at shorter intervals this particular "Follow terrain Counters" can be simulated easily (your last question :). The scripting API gives you full access to marker positions and allows you to insert markers etc. But yes, this editor feature will be added to the scripting API too.

    The scripting API gives access to the road spline data, so indeed you can make your own scripts as well for adding additional objects next to the built-in side object options.

    Thanks,
    Raoul
     
  12. StrategyTron

    StrategyTron

    Joined:
    Feb 20, 2019
    Posts:
    12
    Raoul,

    Excellent!
    When I get to the point for making the runtime roads tool, and if I have some questions when making it, would here be the best place to ask them, or do you have a Discord for this plugin, or any other preferred method of communication?
    Having this capability significantly affects the way we do terrain generation, as well as building placement, which affects other features, so this is one of those features that's super important to get right lol
     
  13. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    You can post questions here, start a private conversation or contact us through our website, what you prefer.

    Good luck anyway with your project!

    Raoul
     
  14. Wetw0rx

    Wetw0rx

    Joined:
    Jun 30, 2017
    Posts:
    93
    Hello there. After playing around with this asset for a couple weeks, I am pretty disappointed. I'm trying to build a mostly dirt road network on a 25 sq km mountainous terrain. The asset itself seems like a very powerful framework but my results have been unsatisfactory.
    The main issue is the road just looks repetitive and tacked on with no really good way of blending the sides in with the terrain. I've imported my own textures and made a few prefab connections and they came out ok but again they stand out from the terrain way too much. I sort of got around this by setting the materials to fade and raising the terrain on the sides of the road to bury the seams but for such a large network of roads, manually touching up the entire road side doesn't strike me as the ideal workflow and it didn't look all that great.
    I bought the pro extension, imported the demo project and even Windridge City (I think that's the name). I like the dirt road example in the demo but haven't been able to match it in my own project. Then I had some issues with missing textures and decals so I had to reimport and hit a steep learning curve.
    I've resorted to just using ER to deform the terrain where I want my roads then deleting ER and painting muddy tire track textures onto the path with the new unity terrain layer system and a rotating brush. This has yielded me the best results so far but I can't help thinking that there HAS TO be a better way to do this. Using ER only to deform the terrain is like driving a Ferrari to the grocery store. I'm not asking for a refund or trying to poopoo the asset but after hours of tweaking, tutorials and forum reading, my road was far from easy.
    I'm not a programmer. Although I can code, I'm coming from an artist/designer angle on a solo project. Recently for performance reasons I decided to rebuild the map and have been putting off the road building part to see if maybe I can adopt a better workflow or technique for achieving my desired look. I'm going for mud/dirt and broken roads like in Rage2 and Fallout. Any advise would be greatly appreciated.
     
    Last edited: Feb 23, 2019
    d1-favero likes this.
  15. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Wetw0rx,

    Sorry to hear you are having difficulties with your dirt tracks.

    In what way are you having issues with blending the dirt tracks with the terrain? Which materials are you using? The blending part can be done using the ER Transparency shader. The visual blending result depends on the dirt track material textures and your terrain splat textures. Baking the shape of the road in the terrain using a dirt type of terrain texture expanding and smoothing out the shape can also help. Indeed demo scenes like the windridge demo can be used as a reference.

    In which way are you having issues with EasyRoads3D building the tracks?

    Thanks,
    Raoul
     
    Last edited: Feb 23, 2019
  16. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    366
    I am working on a FPS, using EasyRoads3d, and TerrainComposer2. TC2 allows me to create multiple terrains that join together nicely, no visible seams, etc. I have found that when I have a 3x3 terrain grid, and apply ER3D to create a complex road network that spans across my terrains, my FPS drops huge. I assume that is due to the fact that the road mesh is one big object. If I only build a small road network on one of the 3 terrains, FPS is still good.

    My question is, what is the recommended workflow for breaking the roads up so that they don't extend onto the other terrain meshes, but still join up? I am assuming that I would have to create multiple "Road Network" objects for each terrain? Can more than one exist in a scene?

    My intent is to create many 3x3 terrain grids and load only the terrain that the player is actually on, and the 8 neighboring terrains that the player can see. Treadmill sort of idea, using World Streamer or something of that nature. Is this do-able, or should I be rethinking my terrain or scene load/unload strategy? Anyone done something similar?

    Mark
     
  17. Wetw0rx

    Wetw0rx

    Joined:
    Jun 30, 2017
    Posts:
    93
    That's totally doable and a solid approach. Separate scenes for the smaller terrains will get you good performance and as long as you're player is not flying there's little chance of noticing. Assets like sectr and world streamer will certainly get you there. You can definitely have more than one road network per scene as well. I once used a very simple asset called scene streamer to good effect. This is a hard problem though with many factors that can influence the exact technique you end up using. Good luck man. Also, kudos for getting Terrain Composer to work for you (nodes aren't my fav). Word of caution: make sure you've got a working model of your streaming terrain before doing too much as you will go through many iterations before working out all the kinks. Weather, player management, quests, physics, interiors, floating point precision, etc in a multi scene terrain require certain decisions be made early on in development or you may have some painful do overs. You might consider having a master scene that contains all your global values and get familiar with async loading and don't destroy on load methods.
    Other options like GPU instancing are also a great way to optimize a scene without having to break it up. It's all up to you.
     
  18. Wetw0rx

    Wetw0rx

    Joined:
    Jun 30, 2017
    Posts:
    93
    I think the easiest solution for me will require tweaking the road texture to blend in on the edges. I'll try the ER transparency shader.
    Btw the shader used by nature manufacture in windridge is an interesting and helpful way of dealing with materials in ER...
    Definitely not knocking ER though. I used it with great results to create some tubing and pipes in a cave/mine and it was great.
    Really, I'm just looking for a bit of guidance as to how I can better blend in the edges of a dirt road, getting convincing tire tracks and good texturing practices friendly to ER.
    Thanks for reply, it's back to Photoshop for me lol. I'm using textures sourced from various sites and altering them in PS to suit my needs. Maybe some decal work is called for as well. I'll post some pics of results and see if maybe you've got an opinion on how to polish them.
     
  19. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Wetw0rx,

    For blending dirt texture textures with the terrain indeed you want to use the ER Road Transparency shader provided that your dirt texture fades out on the alpha channel, hence why I asked which material you use.

    ER s used to create the road shape and builds the geometry. The second part is what this will look like, the material used on the roads together with the look of your terrain textures. Do they go well together...

    At the moment it looks like the issue sou have are more related to making the roads look good with the terrain, not directly ER related? is that right, or do you have ER specific problems / questions?

    Ok, in that case indeed you want to make sure the alpha channel in the textures is setup correctly so the texture will actually blend with the terrain on the edges.

    Thanks,
    Raoul
     
    Last edited: Feb 24, 2019
    Wetw0rx likes this.
  20. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Mad_Mark,

    For the roads part, one long road is indeed not efficient. usually roads already break into road sections after adding crossings. If that is not the case in your scene you can insert I Connectors. This option is available near the bottom of the marker section in the Inspector. It will break the road in two road objects at the selected marker preserving the road shape.

    For streaming this approach is also used by positioning these I Connectors on terrain tile borders so one object will be part of terrain tile A and the other object will be part of terrain tile B. No need to create multiple road network objects.

    Thanks,
    Raoul
     
    syscrusher and hopeful like this.
  21. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Hi Raoul,

    I created a city generator enabling me not to layout the streets of a city manually. For this system the nodes are generated on a specific y-value and streets are generated by projecting those on the terrain and create roads through your api (this is in editor mode, not run-time). However I'm facing an issue that some roads are not created and no error is displayed either. I've checked and all marker positions are correct. In all my runs there were always a number of roads not created. Any idea what could cause this? Unity 2018.3.4 with latest 3.2 beta version of EasyRoads.

    Thanks,

    Wim
     
  22. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Wim,

    Sounds very interesting! But the question is very hard to answer without seeing the code.

    Creating roads through the scripting API does not take anything into account and should build fine unless no control points are passed, or control points are all very close to each other. But you mentioned that you have checked marker positions. Or is this perhaps road type related? And then specifically is the road shape valid?

    Thanks,
    Raoul
     
  23. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    2019-02-24_19-34-06.png
    The system is generating the city streets above the terrain and projects the markers on the terrain for EasyRoads. In above screenshot you see the generator did generate Markers for 6 roads. I understand those single road markers will probably not make it to a road in Easyroads however when looking at the generated roads roads 0 and 3 are totally missing. This is the code I used to generate/translate my markers to easyroads:
    Code (CSharp):
    1. int maxRoad = this.network.GetMaxRoadID();
    2.         for (int i = 0; i <= maxRoad; i++)
    3.         {
    4.             Debug.Log(string.Format("Generating Road {0}", i));
    5.             // determine all markers of a road          
    6.             List<Vector3> positions = new List<Vector3>();
    7.             foreach (var m in Markers)
    8.             {
    9.                 if (m.roadID == i)
    10.                 {
    11.                     positions.Add(PlaceOnTerrain(m.position + transform.position));
    12.                 }
    13.             }
    14.  
    15.             if (positions.Count == 0)
    16.                 Debug.LogWarning(string.Format("No positions for road {0}", i));
    17.             else
    18.             {
    19.                 ERRoad road = roadNetwork.CreateRoad(string.Format("road {0}", i), roadType, positions.ToArray());
    20.                 if (road == null)
    21.                     Debug.LogWarning("Road NOT generated");
    22.                 else
    23.                 {
    24.                     Debug.Log(string.Format("{0} will be added based upon {1} markers.", road.GetName(), positions.Count));
    25.                     roads.Add(road);
    26.                 }
    27.             }
    28.         }
    Nothing special about this, however I tested further and notices they are initially generated but are thrown away when setting up the connections between the roads. So I think I will restart the translation towards Easyroads based upon the crossings as starting points to connect the roads. So, let me fiddle a while further before putting any of your attention to this (will propably a error between the head and the keyboard and not your asset ;-))
     
  24. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    475
    i cant add a road clicking on shift, any ideias?
     
  25. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Wim,

    Yes, it is still hard to give feedback on this. Looking at the code, first thoughts are that this is related to markers. The code only generates the road when marker positions are available. But it will also write to the console when there are no positions so I guess that covers that. Did you check the marker positions for road 0 and 3? Is line 21 triggered for these two roads? Do you get error messages?

    Thanks,
    Raoul
     
  26. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi paulojsam,

    Creating roads is done from the second tab from the left in the Inspector or by pulling out roads from crossing connections.

    Adding marker control points is done using Shift + Click, is that the problem? There are no known issues with Shift + Click to add markers.

    Are you using the full version or the free version and does the scene have more then 1 terrain object? The free version does not support multiple terrain tiles like the full version does. Shift + Click will only work on the terrain that is unity's activeTerrain.

    Thanks,
    Raoul
     
  27. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Hi Raoul,

    In all cases the message 'will be added with positions' is displayed for all roads. I don't get any error messages hence my check if the returned road object would be null or not but apparently they aren't. But as I said I think (need to get deeper into this) is that at the point the roads are getting connected (sorry seems like I didn't provide that code) the roads are merged (hence the apparently disappearance). Was about to check if this is indeed the case as if fi I connect roads 0 and 3 I'll be left with a road named 0 or 3. So any reference to the other roads became invalid.

    Question: what would be the api call to insert/create a crossing? Think to avoid the merge of roads I'll have to start from the crossing and connect the roads.
     
  28. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Wim,

    This involves your scene setup and your code. I would have to see this to provide more feedback. Please send me an email with a link to the project if more feedback is needed.

    For using crossings through the scripting API first a reference to the source connection in the project folder must be created:

    ERConnection sourceConnection = roadNetwork.GetSourceConnectionByName("Default T Crossing");

    Then you can either add an instance to the scene

    ERRoadNetwork.InstantiateConnection(ERConnection sourceConnection, string name, Vector3 position, Vector3 euler)

    or attach it to a road object

    ERRoad.AttachToStart(ERConnection sourceConnection);
    ERRoad.AttachToEnd(ERConnection sourceConnection);

    All 3 will return the newly added ERConnection object.

    Thanks,
    Raoul
     
  29. Walton

    Walton

    Joined:
    May 2, 2015
    Posts:
    78
    Can somebody please help me with this ive tried for a couple of days now to use this package but all i get is this no road textures show : Im using Unity 2018.3.0f2 and easy roads 3d version 3.1.5 and the terrain is made with Gaia..( I think not so easy roads ) getting to wish i had not brought it now.....
     

    Attached Files:

    Last edited: Feb 26, 2019
  30. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hello Walton,

    The white surfaces show how the terrain will be updated to the road shape. Visibility of these white surfaces can be controlled in General Settings > Scene Settings > Hide White Surfaces

    The road texture is material/mesh related. Which version do you have imported? Can you double check this in the most right tab? I see several materials also from the initial beta package before v3 was released. Importing these packages will downgrade the version if v3.1.5 is not re imported afterwards.

    Objects rendering black happens in Unity when normal maps are assigned while the mesh does not have tangent info. In older versions calculating tangent data was optional in General settings > Scene Settings and in the Build Settings. In recent versions this is always calculated. This situation has not been raised for quite some time hence why first thoughts are that an older version is imported at the moment and tangents are not being calculated.

    Does the default road type with the default material work well for you in the demo scene in a fresh v3.1.5 import? And all the road types in the additional demo scene?

    Thanks,
    Raoul
     
    Last edited: Feb 26, 2019
  31. Walton

    Walton

    Joined:
    May 2, 2015
    Posts:
    78
    @raoul Thankyou for your help i reimported 3.1.5 and at the moment all is well, please can you point me in the right direction on how to add a t junction to a road ( Is there a tutorial i can see)?
    Thankyou

    Sorry after trying ti add a T Junction i now get theses error messages for the T crossing and the X crossing:

    Could not extract GUID in text file Assets/EasyRoads3D/Resources/dynamic prefabs/Secondary T Crossing.prefab at line 1474.
    UnityEditor.AssetDatabase:SaveAssets()
    EasyRoads3Dv3Editor.OOCQCDCQOC:CreateDynamicMeshAssets(String[], ERModularBase)
    EasyRoads3Dv3Editor.ODCQOODQOO:OQOOQCDCDO(ERModularBase, OCQDCOCCCC)
    EasyRoads3Dv3Editor.OCQDCOCCCC:OnInspectorGUI()
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    There are 16 of theses errors all with different line numbers
     
  32. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    How was the T junction added? From the error it appears as if

    From the manual:
    ----------------------------------------------------------------------------------------------------

    CREATING AN INTERSECTION IN THE SCENE

    There are three ways to add an intersection in the scene:

    1. Select any marker of a road and select the Crossing / Connection tab In the Inspector. All matching dynamic and custom prefabs will be listed. Press one of these connection prefabs. The prefab will automatically connect to the selected marker.

    NOTE: Depending on the sidewalk status and type of sidewalk if indeed sidewalks are involved, attaching the selected prefab may not work if the sidewalk setup is different.

    2. Select the same crossings tab in the Inspector but without any road selected. This time all available crossing types will be listed. Select the type you want to add in the scene, it will be highlighted, and SHIFT + click in the scene at the position where you want to place this crossing. The crossing will be instantiated at the mouse position.

    In the case a road is selected and only the matching prefabs are displayed while you actually want to add another prefab, you can press the "Instantiate New Connection Prefab" button near the top. This will deselect the road and show all prefabs as described above.

    3. Intersections can be added by snapping markers to other road sections. This can be the same road or another road and can be any marker. After moving the selected marker over another road section the snapping position will be highlighted in blue when a matching connection prefab exists. Different road types are supported, like the railroad crossing in the demo package, as long as a prefab exists with matching road types at positions matching the scene situation.

    NOTE: The third snapping option will not work when custom sidewalk settings are involved not exactly matching the setup of the involved crossings. In that case you can select the marker of the other road where the currently selected road should connect, insert the crossing at that point and connect the initially selected road.

    -------------------------------------------------------------------------------------------------------------------------------

    In v3.2 all this will be more flexible supporting different built-in road types on a single crossing. Roads can also be pulled out of existing roads auto inserting a crossing based on the involved road type.

    The error is related to generating thumbnails of connection prefabs which are required when the "Prefab Display" slider in the connections tab is not all the way to the left (text display). This was updated in v3.1.5 released 2 weeks ago, so far no issues have been reported with this. Which version of Unity do you use? When exactly is it thrown, when the connections tab is active? It appears to be unity prefab ID related. If you are using Unity 2018.3, can you try opening and closing this prefab from the project folder in the prefab editor?

    Thanks,
    Raoul
     
  33. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    379
    Thanks very much, it did work as you suggested and I followed what you told me using the Alignment with Path Normal, and it works right and the results is what I wanted, it looks great and very well.

    You told me the following "Procedural side objects are side objects that will be generated along the track based on a source mesh, the shape of the source mesh will be repeated, following the path"

    Thanks for explaining the difference, but I do not understand it correctly, do you mean that the side objects of a procedural side objects can be based on a custom source mesh that I can put additionaly different than the road?
    Sorry that I still do not understand fully how your awesome asset works and how was developed
     
  34. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    379
    The problem is that I want to be able to add additional markers in specific places to an already created road, and for this is told that I should follow this steps

    1 - Select any of the already available markers of the road that I want to add the new marker
    2 - Put the mouse cursor over the place of the road I want to the insert the marker
    3 - Press the I key (without shift, so it is really the i key) and it will add a new marker below the mouse pointer to the selected road
    4 - But inmediately after inserting the new marker it will deform and bend the road in unpredictable ways where the new marker is, and sometimes better than other times, and it could even break the road
    5 - You can fix the broken marker, using the R key, to remove the added marker, and try again but it will break or bend the road in another way

    There is also something weird because the place where you insert the new marker MUST BE far away from any other already available marker, because if you try to put a new marker near another marker it makes a mess with the road, and I do not know why this is happening

    Would be good if you could insert the markers anywhere in the road and have markers near one from another

    I can show it on video if you want and need to see it more clearly
     
    Last edited: Feb 26, 2019
  35. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi SpaceRay,

    EasyRoads3D supports three different side object types:

    1) The mesh type of side object. It will simply instantiate the source prefab at defined distances along the track. Side objects like lamp posts and the billboard in your example.

    2) Procedural side objects. The source mesh is pulled apart, the position of each vertex is calculated relative to the spline shape so the source mesh bends with the spline/road shape. Once the end of the source mesh is reached it will restart at the beginning. Side objects like guard rails, walls, solid barriers. Optionally, the source mesh can be set up with start / end caps, these will be inserted at the start / end.

    3) Shape type of side objects, similar to two but in this case the shape is defined in the shape editor window and will be repeated at X distance just like for the mesh type of side object.

    The demo package includes various examples of all three.

    Thanks,
    Raou
     
  36. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi,

    Your screenshots on the previous page show that you have quite an irregular road shape all the way in the air with steep angles. It could be the marker insert approach is interfering here, I mentioned that in my reply on the previous page. Can you recreate this problem on a more standard road?

    I just quickly tested this on a road with marker high up in the air. It does actually insert the marker at the correct position.

    Is that a direct result of distances between control points. Significant differences in distances between consecutive markers should be avoided although adjusting the spline strength in the Inspector for the involved markers will give more control over the shape in this situation. Did you try experimenting with this on a more standard road on a flat or hilly terrain just to test?

    Thanks,
    Raoul
     
  37. Walton

    Walton

    Joined:
    May 2, 2015
    Posts:
    78
    RA Road error 1.jpg Hi @raoul
    Still trying to get to grips with this package..( Hence i asked for some tutorials) Now i have problems with the RA Roads.. The first pic shows the RA roads in my test scene ( Fresh New Project ).. The second shows the same road in your Demo scene.. Why can't i get these roads to work??? RA Road error 1.jpg RA Road error 2.jpg RA Road error 1.jpg RA Road error 2.jpg
     
  38. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Hi Raoul,

    still generating city here ;-) I did get back to the drawing table though as I made it way to complicate. The new logic starts with identifying the crossings and place those in the scene. Now I"m wondering how I can (using api calls) mimic the extrusion of a road out of a crossing (like we can do in the editor). Any suggestions?

    Thanks,

    Wim
     
  39. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Walton,

    The RA Road in combination with the RA Crossing prefab is an example of a custom prefab, a mesh crossing imported in the system rather then a built-in customizable crossing.

    The road part uses a texture atlas approach this is what is causing the problem when starting a new road of this type. It can be fixed by pressing the "Flip Texture" button. Roads pulled out of the RA Crossing prefab will look just fine anyway.

    The demo package description says that it is recommended to import this package in a new project. The package primarily is intended for learning purposes, getting familiar with the tool and demonstrating different ways of doing things both regarding roads as for side objects. The RA examples are not directly intended to be used in a project. The custom prefab system is especially useful for artists who create their own models. These models can be imported in the system, they will behave similar as built-in crossings, roads can be attached and new roads can be pulled out of the crossing connections.

    Thanks,
    Raoul
     
  40. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Wim,

    The scripting API does not include an interface for this sort of thing.

    The logic in the Unity Editor is:

    1) get the mouse position
    2) check if it is within a specific range a crossing connection
    3) if the mouse button is pressed, check the distance to the start the position
    4) build the new road after a short distance
    5) update the second marker position while moving away from the start position
    6) Attach the road to the crossing after releasing the mouse button.

    Step 4, 5 and 6 involve the scripting API.

    ERRoadNetwork.CreateRoad(string name, ERRoadType type, Vector3[] markers)
    ERRoad.SetMarkerPosition(int index, Vector3 position)
    ERRoad.ConnectToStart(ERConnection connectionObject, int connectionIndex)

    http://unityterraintools.com/EasyRoads3D/v3/html/scriptingAPI.html

    Thanks,
    Raoul
     
  41. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Hi Raoul, thanks. I can work with the steps layed out above to replicate this in my generation process.
     
  42. Walton

    Walton

    Joined:
    May 2, 2015
    Posts:
    78
    OK Thanks @raoul

    I will get there in the end.... :)
     
  43. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Hi @raoul,

    Looks like I made the correct decision in redesigning the network starting out of the crossings instead of the roads.
    2019-02-28_14-12-47.png
    Generating a complex city infrastructure with only 3 button clicks. Thanks for the support, this is a huge timesaver for my ongoing openworld project.
     
    syscrusher, hopeful and raoul like this.
  44. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Hi @raoul,
    seems like I'm strumbling on my next issue. As my world is large I'm using a world origin move routine to prevent the famous floating point issue. I noticed that the roads don't move with this system so the roads are on a wrong place at runtime than at design time. I tried everything possible like finalizing the road network or even set the origin of the Road Network myself but nothing seems to aid me in this quest. Any suggestions?
     
  45. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    Hi Wim,

    How are you moving the roads at runtime?

    Inside the Unity editor the roadnetwork object position is locked to (0,0,0). This is done to avoid the situation where it is accidentally moved. It will be hard to get it back at the original position with the roads matching the terrain after the scene was saved and reopened.

    The scripting API has an option ERRoadNetwork.Translate(Vector3 positionChange) to move the road network. But this is more intended for inside the Unity editor.

    Finalizing the road network will remove all script components. In that state there is no code that will lock the road network to (0,0,0) even in the Unity editor.

    Thanks,
    Raoul
     
  46. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Hi Raoul,

    I'm reposition my game world using this piece of code:
    Code (CSharp):
    1. for (int z = 0; z < SceneManager.sceneCount; z++)
    2.                 {
    3.                     foreach (GameObject g in SceneManager.GetSceneAt(z).GetRootGameObjects())
    4.                     {
    5.                         //if (g.name != "0-Point") //&& g.name != "Sky Dome"
    6.                         g.transform.position -= cameraPosition;
    7.                     }
    8.                 }
    So, after finalizing the road network this is the result (only the crossing are there and the bounding colliders of the roads I guess?)
    2019-03-01_15-51-17.png
    The actual roads are drawn somewhere on a complete strange location:
    2019-03-01_15-52-10.png
    Could it be there is some math going on in the shaders of the roads themselves? Any idea how to fix this?
     
  47. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    If it is a finalized road network, are indeed all script components removed, also from the roads?

    Can you select some road objects and check the position. Is it the position correct?

    There is no math in the EasyRoads3D shaders if these are the shaders you are using.

    Do you mean this is where the roads are positioned right after finalizing the road network as you wrote? Or is the image the result after running your code?

    Thanks,
    Raoul
     
  48. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    647
    Yes, finalized with all scripts gone.
    (looking at the finalized network) I see some strange things on the generate roads. For the crossing this seems to be ok, and those are also repositioned at runtime as expected:
    2019-03-01_16-27-56.png
    Looking at the transforms of the roads this is seen:
    2019-03-01_16-29-22.png
    So the roads are always drawn at 0,0,0? This is the cause why they are not at their location. Why are they all at the 0 vector location and drawn correct?

    Good to know.

    The roads seem to be fine after finalizing the network. The result show is at runtime when the world origin is shifting. The crossings stay in there place so strange the roads are drawn way off. As stated above as the initial positions of all roads seem to be 0 a shift in origin is placing them at the offsetted 0 located and not where they should be.

    Edit: double checked at runtime and the roads are indeed drawn at the shifted origin, iso the expected positions.
     
  49. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    4,617
    The pivot point of crossing are in the center of the mesh and are positioned accordingly. The pivot point of roads is by default at (0,0,0), also when creating your road network, when not finalized. Alternatively this can be set to the center of the mesh bounds.

    A very simple example using the demo scene:

    1) Put it in Build Mode
    3) Finalized it
    2) Moved both the terrain and road network 500 units on x axis

    Everything looks as expected also at runtime and also when selecting the road network in the hierarchy, the roads do not move back to their original position or another position.

    Can you send me a project including your scripts at runtime so I can look at it?

    Thanks,
    Raoul
     
    Last edited: Mar 2, 2019
  50. Walton

    Walton

    Joined:
    May 2, 2015
    Posts:
    78
    @raoul

    Still trying to learn...lol. have setup a sidewalk to work from the custom prefabs... the only think i cant get to work one the UVs come from one of the sides... ( see attached pic )

    Please point me in the right direction

    Thank you Sidewalk error 3.jpg