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
    Hi James, glad to hear this is resolved! I will check why initially dragging the new prefab in the scene resulted in these errors.

    Thanks,
    Raoul
     
    Last edited: Oct 4, 2017
  2. raoul

    raoul

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

    By default the system calculates the UVs by distance. That is probably what you see in the first post.

    You can indeed manually adjust the UVs in the UV Editor window. When using the same texture on the road as on the connection prefab and the UV coordinates on the road match the UV coordinates of the connection vertices, the "Copy UVs from Source Mesh" is the easiest method.

    Than ks,
    Raoul
     
    AndrewBeers likes this.
  3. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    Hello, Raoul!

    I've finally gotten around to trying out this asset to evaluate whether it's suitable to our needs or not. Unfortunately, I've run into a problem right off the bat. I'm sure it's something that I've missed and I'm hoping you could help me figure out what that is.

    My situation is such that there's no terrain before I press play. During play the terrain will be loaded from data. Terrain is loaded and unloaded dynamically. I need to add roads programmatically, but first I'm trying to learn how to use EasyRoads3D as a tool.

    If I create a terrain before play then EasyRoads3D works as I expect it. The problem I have is that EasyRoads3D won't touch the terrains which are generated during play. The generated terrains have automatically received the ER Terrain component, so that's not the issue. Hopefully you already know what I need to do, but I will include all the error messages that I get along the way anyway. I've tried adding the Road Network both during and before play.

    1. During play
    I get this error when I add the Road Network. I get the same error when I deselect and reselect the Road Network.
    RuntimeAddRoadNetwork.png

    When I've added a road object and want to build the terrain I have the following two options for terrain and I don't know what either of them are.
    TerrainTab.png

    When I build the terrain with the first option there is no effect.

    When I build the terrain with the second option I get an error message and there's a loading bar that doesn't move and I have to terminate Unity to end play mode and make it go away.
    BuildRoad.png

    2. Before play
    I get this error when I add the Road Network. It speaks for itself.
    AddRoadNetwork.png

    When I've added a road object and want to build the terrain I have only "All Terrains" as an option. Building with that option has no effect.

    ----

    It seems to me that the Road Network is unaware of any terrain that wasn't there when it was created. I've not seen any option to update what terrains the Road Network knows about. This is something I'm going to have to do a lot, since terrain will be loaded and unloaded dynamically.
     
  4. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735

    Hi NordstroemSAAB,

    The first thing to look at is the package import because the available terrain names are not displayed correctly.

    This is usually the case when your project is set to use "Force Text" for Assets Serialization (Edit > Project Settings > Editor) instead of the default "Mixed" option. Is that the case?

    This situation is covered in the Troubleshooting page of the manual. This is a workaround:

    Create a new empty project (Assets Serialization is set to Mixed), import the package, switch to "Force Text" and export the full assets folder to a new package. Import this package in your project that also uses "Force Text".

    Regarding the terrain it is unclear what your exact steps are.

    You mentioned that all works well when working the conventional way, inside the Unity editor. A terrain is available, you can add roads and the terrain updates according the road shape.

    What are your steps when doing all this in Unity Play Mode? Are the roads added manually or through code like in the runtime script example? It looks like this is done manually which seems not a reliable way when the editor is in Play Mode. For anything runtime related, certainly when figuring out if the tool is suitable, meaning can it do what you eventually want to do with it, I would try to use the scripting API. This is what you eventually will be doing, add roads programmatically.

    Thanks,
    Raoul
     
  5. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    I read about that on the troubleshooting page. I thought just changing to "Mixed" would fix it, but apparently it didn't and it reset when I terminated Unity. The package you're referring to is only the EasyRoads3D package right? Because this project is pretty big and I don't really want to affect anything aside from that which I am working on.

    Yes, I'm trying to add roads manually. This is because I wanted to learn to use EasyRoads3D as a tool first so that I can understand how it "thinks". If you insist that it doesn't work in play mode then I guess I'll have to jump right into the code and try out the API.
     
  6. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Yes, the EasyRoads3D package

    1. Create a new project,
    2. Import EasyRoads3D
    3. Change Assets Serialization to "Force Text"
    4. Export the EasyRoads3D folder to a new package.
    5. Import this new package in your real project.

    It is definitely recommended to try the tool out inside the Unity editor, get familiar with everything. The current API implementation is based on that although not all editor functionality is available yet through the API.

    But I wouldn't recommend doing all that with Unity being in Play Mode, that is what the scripting API is for. You can try out the runtime scene and script. This is a simple example of creating a road at runtime. you can also use that script as a starting point to test road creation on your procedurally generated terrain.

    Thanks,
    Raoul
     
  7. AKComp

    AKComp

    Joined:
    Aug 22, 2014
    Posts:
    26
    hey i got this error thanks
     
  8. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hello K4R4D3L1,

    Could you provide more info?

    In which version does this happen? When exactly does it happen? How can we recreate this?

    Thanks,
    Raoul
     
    Last edited: Oct 5, 2017
  9. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hi,

    I want to use Easy Road v3 with World Streamer.

    My issue is World streamer use the road Transform Position to know how to split the scene and when to Load or Unload the road part mesh based on player postion. I noticed that easy road put all the roads pivot in (0,0,0) ! So my questions :

    1/ How i can tell Easy Road to set the road pivot in the road center pos and not in vector3.zero pos (specialy when storing the mesh road asset) ?
    2/ Do you have any recommondations using ERv3 with World Streamer ?

    Thank you so much
     
  10. raoul

    raoul

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

    We are not familiar with World Streamer. Is it indeed only possible to do this by transform position? Not by looking at the bounding box or the center of the bounding box?

    If that is indeed impossible a little script can fix that. Go through all road objects, get the center of the bounding box, place the object at that position and recalculate the vertex positions relative to this new position.

    This could be added to the scripting API.

    As for recommendations, the road objects are ordinary Unity game objects, I would think this works similar as any other object imported into Unity.

    Thanks,
    Raoul
     
  11. AKComp

    AKComp

    Joined:
    Aug 22, 2014
    Posts:
    26
    Hey,
    im usin EasyRoads V3, my uinty version 5.6, when i import easyroads and create new "easyroadobject", it happen thanks
     
  12. raoul

    raoul

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

    What exactly do you mean with creating a new "easyroadobject", Do you mean when you create a new Road Network object through the menu? That sounds like a package import issue.

    Could you provide full steps what you do after the the package import? Do you get other errors?

    Thanks,
    Raoul
     
  13. AKComp

    AKComp

    Joined:
    Aug 22, 2014
    Posts:
    26
    no i don't get any error when import package. after import, one time i get this error and after, when create a new road network object, i get same error again
     
  14. AKComp

    AKComp

    Joined:
    Aug 22, 2014
    Posts:
    26
    i reimport package and solve this error, thank you :)
     
    raoul likes this.
  15. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Yes. World streamer split the gloable scene on smaller one based on objects position.

    This can be the solution. if the road position are the center of the bounding box and not vector3.zero by default. Can you please share the script ?

    Thanks
     
  16. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Do you mean that is the only position? This can indeed not be done by looking at the bounding box of an object or the center position of the bounding box?

    I remember a post in the past confirming that it is does work well. But this could be another streaming package.

    I only mentioned this as a workaround, currently there is no script like this to share. But it is fairly simple, get all road network child objects with meshfilters. If the object is positioned at vector3.zero, get the center of the bounding box. Go through all vertices and recalculate the position relative to this center position. Set the object to this position. I will add this to the scripting API.

    Thanks,
    Raoul
     
  17. BigBite

    BigBite

    Joined:
    Feb 20, 2013
    Posts:
    108
    Hello, can I use this tool to build road-like networks that somewhat adhere to a grid on flat mesh? Don't need terrain functionality for what I'm after. Oh, and would I be able to that at runtime?
     
  18. LastChaos

    LastChaos

    Joined:
    Dec 9, 2013
    Posts:
    39
    upload_2017-10-8_15-14-2.png

    Unity 2017.1.1f1
     
  19. raoul

    raoul

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

    That is a v2 script.

    For v3 please follow the import instructions in the EasyRoads3D asset store description. Or, since you already imported the full package contents, please check the _Readme file in the EasyRoads3D root directory.

    In short, there is a v3 beta unitypackage in that folder. Looking at the path you already moved the EasyRoads3D folder. So double clicking that v3 beta package will import v3 only assets into /Assets/EasyRoads3D/. Afterwards remove the folder /Assets/Workshop/Tools/EasyRoads3D/ You can now move the new v3 folder to this folder if you want.

    Thanks,
    Raoul
     
  20. raoul

    raoul

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

    At first it will ask for a Unity terrain object. You can drop a temporary terrain object in the scene to deal with that. In "General Settings > Scene Settings" you will see "Terrain Mesh". Drop your terrain mesh in this slot. Indeed you will lose the terrain flatten functionality, but that doesn't seem to be required in your case anyway.

    Also in "General Settings > Scene Settings" you will see Global and Local Grid options (the Hotkeys J, K and L). You can set the grid size and rotation. Road markers and crossings will snap to grid cross points.

    You can create roads at runtime although the scripting API is not fully implemented yet. Setting up grids was added later I am 100% certain if that will work yet if grid snapping is active. If not, that is probably fairly easy to update. But this is actually more editor functionality, the grid only displays in the Scene View window.

    Thanks,
    Raoul
     
  21. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
    Hi, Is it possible to just add side objects and not a road mesh?
     
  22. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    sheffieldlad likes this.
  23. sheffieldlad

    sheffieldlad

    Joined:
    Oct 9, 2013
    Posts:
    154
  24. FrikkieRSA

    FrikkieRSA

    Joined:
    Mar 30, 2017
    Posts:
    27
    Hi @raoul.

    I would like to know why I cannot change the road width after a connection? For example I like the road shape that is created from the Train Crossing Single Lane custom prefab, however I would like to increase the width of the road to two lanes or something. When I delete the connected crossing prefab the road maintains it's shape and I can then change the width of the road, but when I do this it reverts the road to a normal flat shape. I like the road with a shape, in other words it does not need to float above the ground. With this I should also be able to get away with a lower heightmap resolution. Is there an easier way to achieve this shaped road with adjustable width?

    Sorry, I forgot to mention, I am using v3 beta 8.6 and playing around in your demo scene.

    I also noticed just now that the roads' colliders aren't being built. Why is this?
     
    Last edited: Oct 10, 2017
  25. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi nikolai-niedermeier,

    In v3 there are two types of roads / crossings. Dynamic built-in which the width is editable. And custom crossings / roads based on imported meshed. These are not editable regarding the width.

    The road you mention is part of the custom road network example which also includes the railroad crossing. If you change the width they will indeed lose their original "custom" shape and revert to a built-in road type.

    Once sub division is added to the dyamic built-in crossing system it will be possible to create dynamic road types like the one that extrudes from the rail road crossing.

    At this moment what you want can be achieved by importing a mesh model of the road shape you need, like a two lane version of the rail road crossing example. You can import that source model in a modelling app, stretch the road section to match a two lane road and import back into the system like done in the second Custom Road Network videos.

    That is right, while testing things adding the updated mesh to the mesh collider was temporarily switched off. It wasn't switched back on for the 8.6 release. This will work again in the next release. In the meantime you can add a meshcollider manually for testing.

    Thanks,
    Raoul
     
  26. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    159
    Hello, this my first post about this project... I'm very impressed about it, I saw some time ago and the screenshots are amazing!

    I'm about to buy it for my virtual city, but before buying I have some simple questions...

    1 - Does it still need Unity terrain, or can work without it? I don't like Unity terrain since it is "heavy" for most mobile phones. Will it work on a simple plane/quad?

    2 - Is it possible exporting the generated roads to a 3D mesh, for use in other scenes or 3D modeling programs like Blender? If this feature is not native, may we export with other tools? (there are some free tools that export the 3D meshes on the scene).
     
  27. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi Marcos-Elias,

    Thank you, glad to hear you like it!

    The same question was asked recently. After adding the road network object to the scene it will ask for a Unity terrain object. You can drop a temporary terrain object in the scene to deal with that. In "General Settings > Scene Settings" you will see "Terrain Mesh". Drop your terrain mesh in this slot, you can now lay out your roads on this mesh terrain. But you will lose the terrain flatten functionality which is optimized for the Unity terrain object.

    You can export both the full road network and individual objects. There is also an option to store the mesh assets in the assets folder. That way you can create a prefab from the road network and use it in another scene / project.

    But you can indeed also use one of the available external export scripts.

    Thanks,
    Raoul
     
    Last edited: Oct 11, 2017
    Marcos-Elias likes this.
  28. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    159
    Perfect, thanks! I bought it a few hours ago, it will help me a lot. Very nice tool!
     
    raoul likes this.
  29. FrikkieRSA

    FrikkieRSA

    Joined:
    Mar 30, 2017
    Posts:
    27
    Ok, I think I understand now. Will this feature be included in the final version 3 and when do you expect to be releasing it? I am surprised that custom road shapes was not a lot more sought after feature. Roads are never completely flat on the ground and it will be very useful to change the width of the road (for example in hairpin corners the roads are always a lot wider).

    Thanks, I will try this.
     
  30. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Not in the the final 3.0 version because that will be released very soon, but it is planned for v3.x.

    You can change road shapes regarding the width per marker, also for default road shapes. The N key toggles this on/off, you will see selectable handles at roads shape node positions. For the default road type this is on the left and right side of the road only. This way you can make the road wider in hairpins.

    As for features like custom road shapes, there are many requests, and regarding roads and crossings, there are many different situations. A project like this is never finished. Hence why the custom connection system was added at an early stage, you are not limited to what is built-in.

    Thanks,
    Raoul
     
  31. FrikkieRSA

    FrikkieRSA

    Joined:
    Mar 30, 2017
    Posts:
    27
    Awesome, now I see what you mean with the width still being adjustable (and the shape too). Thanks for the help. Sorry if I seem unhappy with all your features, I just don't know the system well enough.
     
  32. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    No problem :), I completely understand what you mean, extruded roads like what you were partially referring at is on the list. It depends on demand on what has priority. So far there have not been that many requests for this, perhaps because it comes at a cost too, higher poly count etc. But that is why it has not been added yet.

    Although making this work with dynamic crossings is a little bit more complicated, by itself it is fairly easy to implement. And as a temporary workaround you can have this interact with dynamic crossings as well by using an I Connector. Flat roads connected to dynamic crossings, an I connector for the transition between flat and extruded roads.

    Thanks,
    Raoul
     
  33. LastChaos

    LastChaos

    Joined:
    Dec 9, 2013
    Posts:
    39
    When I try to move (or edit this part) the selected point, I get the following error:

    upload_2017-10-11_23-21-7.png

    Some ideas?

    P.S. I can't remove this road part, Unity crashes.

    Unity 2017.1.1f1
     
  34. raoul

    raoul

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

    Something similar was recently reported. It happened as a result of the specific combination of T crossings and "Activate Bending" being switched on for all three T crossings.

    Can you try to switch off "Activate Bending" on any of these 3 crossings?

    Thanks,
    Raoul
     
  35. LastChaos

    LastChaos

    Joined:
    Dec 9, 2013
    Posts:
    39
    Thanks. That helped :)
     
  36. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Good to hear that :)

    This will be fixed in the next update so no need to switch off Activate Bending.

    Thanks,
    Raoul
     
    hopeful likes this.
  37. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96

    Hi All,

    Unfortunately I've run into the same issue.

    "Broken text PPtr in file(Assets/EasyRoads3D/Resources/dynamic prefabs/Default X Crossing.prefab). Local file identifier (118426) doesn't exist!
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()"


    Tryptic, could you solve it somehow? I can reproduce it any time.

    Environment:
    1. Win10 x64
    2. Unity 2017.1.1f1
    3. EasyRoads3D v3 beta 8.6
    Steps I did:
    Just created a heightmap, imported the EasyRoads3d unitypackage, started a build as a Win32 executable. If I remove all the imported elements of the ER3D asset, it builds well. If I just import (but don't place any road node, I do not touch anything else, just import), I have the mentioned build error.

    Raoul, Tryptic, could you please let me know if you solved this? Thank you.
     
  38. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hello Yany,

    This seems to happen occasionally in 2017.1. I have seen it as well but it is harmless, the "Default X Crossing" to which the message points, works just fine. It appears to be a Unity thing not affecting EasyRoads3D. Search around on "Broken text PPtr"

    Or are are you having other issues as well?

    Or does this actually happen on building the project? I will check again. In any case it is save to remove this asset for a final build or place it temporarily outside the resources folder?.

    Thanks,
    Raoul
     
    Last edited: Oct 13, 2017
  39. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    Thanks for the fast response. Actually I cannot build any binary as it's a fatal error:
    upload_2017-10-13_13-42-21.png

    I cannot build neither for Win32 Standalone nor Android APK. Please help me get over this as it just blocks me advance.

    I also get 2 warnings right after importing ER3D:
    I don't know whether it is in relation with the issue.


    Thank you.
     
    Last edited: Oct 13, 2017
  40. raoul

    raoul

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

    The error is different. How does this relate to LastChaos post? Can you show a clear setup when this error happens (like the image LastChaos posted) so we can recreate it?

    Thanks,
    Raoul
     
    Last edited: Oct 13, 2017
  41. raoul

    raoul

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

    Have you tried what I suggested in my previous post? Move this dynamic prefab outside the resources folder so Unity will not include it in the build?

    Or

    I justed tested this in 2017.2. I can confirm the error and the Unity crash after attempting to create a build.

    I restarted Unity and selected the specific "Default X Crossing" asset in /Assets/EasyRoads3D/Resources/dynamic prefabs/. A similar "Broken text PPtr..." error appeared. I then right clicked the file and did a Reimport, and restarted Unity, just in case...

    Building a Windows standalone worked well.

    Can you try this?

    Thanks,
    Raoul
     
  42. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    When I moved the "Default X Crossing" prefab away, it built well. However when I clicked on reimport I got a lot of errors:
    upload_2017-10-13_14-57-50.png

    Clicking on reimport seemingly does nothing, it does not put the prefab back to it's original place, just produces the above errors. However it's not clear to me if crossroads should work during editing the road while the prefab is moved away.

    I still have not placed any roads on the map yet.
     
  43. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Did the first line (Broken text PPtr...) indeed appear when selecting that asset? Not when doing the reimport?

    And was the reimport done on that particular asset or on Reimport All? I don't get any errors when reimporting that particular asset.

    For sure the Reimport will not put the prefab back to it's original place, that is not how a Unity Reimport on a partciluar asset works. Please put it back manually to test if the build works well after the reimport.

    Can you otherwise reimport the full package. Select that asset, do you get the "Broken text PPtr..." message? In that case reimport that asset only, restart Unity and try a new build.

    Thanks,
    Raoul
     
  44. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    1. You are right, I get the "Broken..." error when I just select the asset simply by clicking on it.
    2. After that if I clear the console and clicking away and back on the item I don't see it again.
    3. After Restarting the Unity I get the error again... and this time it's displayed once only again.
    4. After building and running the project and return back to unity I get the error again if I click on the asset again.
    5. I get those 5 pieces of NullReferenceExceptions when I click on the "Roundabout 4 connections" object in the dynamic prefabs resource folder. It drops 5 exceptions every time I click on that no matter what.
     
  45. raoul

    raoul

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

    The 5 steps do not include the part of right clicking on the "Default X Crossing" prefab in the assets folder (after step 1) and selecting "Reimport".

    Did you do that? For me that fixed the build issue after restarting Unity first. After doing that asset Reimport it also no longers throws that warning when selecting that prefab in the assets folder after a Unity restart.

    Step 5 works well on our end in 2017.2. Selecting "/Assets/EasyRoads3D/Resources/dynamic prefabs/Roundabout 4 connections" does not throw any errors or warnings in the console. Can you instantiate that prefab correctly in the scene from the crossings tab in the Inspector (3rd tab from the left) and can you connect roads, pull out new roads from the roundabout connections?

    Thanks,
    Raoul
     
  46. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    Yes, reimporting fixed the build issue, sorry, I forgot to mention, but the errors I quoted are still thrown when I click on the prefabs. For the roundabout I get a lot of errors when it's selected in the project window and I just hover the mouse over the Unity UI. However I can see black surfaces on the roundabout when I instantiate one as you specified:

    upload_2017-10-13_18-8-42.png
     
  47. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Ok, so the Build issues are indeed fixed now.

    I am not sure about those errors/warning when selecting the prefab in the project folder. It doesn't happen over here. If you want you can email me a simple project, hopefully it does throw the same warnnings.

    In any case, there is no reason to select these source prefabs in the project folder unless you want to change them. They shouldn't be used directly in the scene. Scene instances are created through the Crossings tab in the Inspector. Select the prefab you want to instantiate and shift + click in the scene.

    Those black areas are a result of the material using a normal map while that specific road section does not have Tangent info available. If you check the materials you will see that the material on the roundabout section does not have a normalmap assigned, that is why it doesn't render in black. So the roundabout prefab mesh as it is in the project folder, is not entirely up to date with regard to the currently assigned materials.

    However, with "Calculate Road Tangents" toggled on in the default Build settings, this will correct itself when switching to Build mode. Also when switching back to Edit Mode afterwards.

    Thanks,
    Raoul
     
    Last edited: Oct 13, 2017
    Yany likes this.
  48. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    Okay, we continued in pm, however thanks for your support, roundabouts are fixed just like you described...
     
    tryptic and raoul like this.
  49. NordstroemSAAB

    NordstroemSAAB

    Joined:
    Aug 3, 2017
    Posts:
    50
    Hello, Raoul!

    It's been slow going due to a lot of unrelated tasks, but I've finally gotten so far as to start using the EasyRoads API. I have however encountered a problem that stops me dead in my tracks. I have no idea what the ERRoadNetwork class needs for its constructor to work. When I call the constructor something inside fails and throws a NullReferenceException. The error message isn't descriptive enough to tell me any more than that it happens in the constructor or a function called by the constructor.

    We create our terrains in runtime and what I'm trying to do is to add roads to each terrain we create. In the function where I'm trying to create the ERRoadNetwork I have access to the variable _goTerrain which is the terrain GameObject and _terrain which is the Terrain component of said game object. A TerrainData has just been assigned to _terrain and _goTerrain has been set to active. I didn't write that part of the code, but my colleague told me that at this point the terrain should be in the scene. Right after that I try to run the ERRoadNetwork constructor, but it throws a NullReferenceException.

    I've tried adding a temporary terrain in the scene in edit mode, thinking that it might need to find a terrain from the start, but that didn't help. I also tried adding a RoadNetwork in edit mode, but the constructor in the code still throws a NullReferenceException.

    What conditions do I need to fulfil before I can properly initiate an ERRoadNetwork? The example runtime script doesn't seem to imply any specific requirements.

    Edit: Actually, the error appear to happen in something called ERModularBase. It's called by the ERRoadNetwork constructor.
    ERerror.png
     
    Last edited: Oct 17, 2017
  50. raoul

    raoul

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

    ERRoadNetwork network = new ERRoadNetwork();

    This by itself does not raise any errors, even if there is no unity terrain object in the scene. This is tested both through an editor script and at runtime.

    You mentioned the example runtime script. Have you tried the example runtime scene? How does that work for you?

    Can you make more clear how you are using this, including code?

    Thanks,
    Raoul