# EasyRoads3D v3 - the upcoming new road system

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

1. ### Barritico

Joined:
Jun 9, 2017
Posts:
234
Hola.

Voy a exponer unos problemas y unas dudas. Lo hago en Español y luego pongo la traducción al inglés. Me temo que cuando pongo el inglés no se me entiende muy bien y sé que el autor habla Español.

Me dedico a hacer un juego de competición de coches. Un juego off-road. Los tramos de competición tienen, en ocasiones, hasta 40 km. de recorrido.

Hasta ahora tenía ese recorrido en tramos de carretera de 1.5 km (aproximadamente) como máximo. Sin embargo, y debido a comportamientos extraños de las físicas de los colisionables de las ruedas, me han recomendado no hacer tramos superiores a 200-300 mts.

Así que estoy volviendo a trocear las carreteras. Y me encuentro con lo siguiente.

1- Una cosa que hay que evitar (según me han aconsejado) es que existan diferencias de pendiente demasiado grandes para que la malla no se vea afectada. Por lo tanto utilizo muy el botón "Distribute Y Evenly". El problema me surge ahora que he "cortado" las carreteras usando un I CONNECTOR. Distribuir Y ya no funciona bien ya que entre una y otra carretera se produce un "salto". La pregunta es: ¿hay forma de seleccionar dos módulos de carreteras para hacer esta operación? Y, en caso negativo... ¿cómo podría solucionarlo? Es imposible coger la última marca de la carretera 1 y la primera de la carretera 2 para ponerles una pendiente coherente ya que no permite variar el valor y de cada marca mientras exista el I Connector.

En las imágenes se puede apreciar cómo el "conector" ha generado una irregularidad que anteriormente, cuando era una única carretera, no existía.

Gracias

EasyRoad está en la última versión.
Unity 2019.2.20f1

******************************************************************************

Hi.

I will expose some problems and doubts. I do it in Spanish and then I put the English translation. I'm afraid that when I speak English I don't understand very well and I know that the author speaks Spanish.

I dedicate myself to making a car racing game. An off-road game. The sections of competition sometimes have up to 40 km. travel.

Until now I had that route in sections of road of 1.5 km (approximately) maximum. However, and due to strange behavior of the physical collision of the wheels, I have been recommended not to make stretches greater than 200-300 meters.

So I'm cutting the roads again. And I find the following.

1- One thing to avoid (as I have been advised) is that there are too large slope differences so that the mesh is not affected. Therefore I use the "Distribute And Evenly" button very much. The problem arises now that I have "cut" the roads using an I CONNECTOR. Distribute And it no longer works well since between one road and another there is a "jump". The question is: is there a way to select two road modules to do this operation? And, if not ... how could I solve it? It is impossible to take the last mark of the road 1 and the first of the road 2 to put a consistent slope since it does not allow to vary the value and of each brand while the I Connector exists.

In the images you can see how the "connector" has generated an irregularity that previously, when it was a single road, did not exist.

Thanks!!!

EasyRoad update last version.
Unity 2019.2.20f1

2. ### JamesWjRose

Joined:
Apr 13, 2017
Posts:
426
All my roads are made in the editor, NOT via code. I am attempting a couple of test beds to see if the issue I am having is with 3.3 + Unity 2019.3 or something else. I will let you know what I find.

raoul likes this.
3. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi Barritico,

We are indeed located in Spain and speak a little bit Spanish, we are Dutch. Since this is a public forum I will respond in English. Please let me know if something is not clear.

So the situation is that you have long roads cut in sections and connected with I Connectors. And you want to use the "Distribute Y Evenly" option, which is road object / section specific, across multiple sections.

That is indeed not supported at the moment. I will make a note of this. The system already supports the selection of multiple markers across different road objects. So when these selected road sections are connected, it should be relatively simple to have "Distribute Y Evenly" and the other alignment options also work across these road sections.

Meanwhile, in the latest versions two roads of the same type can be merged quickly in one by snapping the markers together. So you could simply select the I Connector, delete it, snap the two markers so the two road sections merge in one, apply "Distribute Y Evenly" and insert the I Connector again.

Thanks,
Raoul

Last edited: Feb 12, 2020
Barritico likes this.
4. ### Barritico

Joined:
Jun 9, 2017
Posts:
234
Always so fast and effective
Thanks!!!

raoul and JamesWjRose like this.
5. ### JamesWjRose

Joined:
Apr 13, 2017
Posts:
426
[QUOTE = "Barritico, post: 5473026, member: 1409590"] Always so fast and effective
Thanks !!! [/ QUOTE]

Raoul is terrific like that. It's a very good asset, and my game could not exist without it, but it's the support that is fabulous!

Barritico and raoul like this.
6. ### TurboHermit

Joined:
Dec 20, 2011
Posts:
16
Hey there Raoul, we recently bought your tool and I'm having some trouble getting it to work in a iOS build. If we have a Road Network in our scene and try to build it, it fails with the following error:

BUILD FAILS WITH AN ERROR "DXT1 COMPRESSED TEXTURES ARE NOT SUPPORTED WHEN PUBLISHING TO IPHONE"

However if we remove the Road Network from the scene, it builds just fine. We're using the default materials and textures provided with the package. I've tried isolating the issue by deleting all textures and images in the pack (which obviously causes some other problems) but even then the build fails with the same error.

Is this something you folks encountered before?

P.S. we're using Unity 2019.2.15f1

7. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi TurboHermit,

This seems texture import settings related.

Which packages do you have imported? Have you checked the materials and the import settings of the assigned textures?

What is strange is that the problem does not disappear after deleting all textures. Does the error / warning point to a specific texture?

Is this related? https://issuetracker.unity3d.com/is...s-are-not-supported-when-publishing-to-iphone

Thanks,
Raoul

8. ### TurboHermit

Joined:
Dec 20, 2011
Posts:
16
Turns out finalizing the Road System fixed the problem, which makes sense in hindsight haha. I couldn't find it as a necessary step to build in the manual, though I might have missed it. I suppose parts of the editor gets build as well if not finalized? Maybe the error returns based on the editor icons or something.

9. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi TurboHermit,

Thank you for the update and glad to hear you managed to resolve that.

"Finalize" is optional and is indeed recommended when the scripting API is not used at runtime. It will remove the script components from the objects. We will check if we can reproduce this, and see which textures are involved.

Thanks,
Raoul

10. ### Barritico

Joined:
Jun 9, 2017
Posts:
234
Hello again

I tried to remove the "I CONNECTOR" from the roads to join it again. It must be very clumsy, but it is impossible for me.

Roads have the same textures, materials and sizes. But I am unable to select the two that I want to join after evenly distributing the Y axis.

If I "drag" the last mark of one of them to join it to the first of the next, neither does the union occur. They overlap.

I do not know what I do badly.

You can help?

11. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi Barritico,

Which version do you use?

When moving the start / end of one road section towards the start / end of another road section the marker of the other road will lit up when inside snapping range. If the road type is the same the maker will be blue, the roads will merge. The marker will lit up in orange when they are not of the same road type, an I Connector will be inserted again.

Thanks,
Raoul

12. ### donkey0t

Joined:
Oct 23, 2016
Posts:
28
API question. I have got an ERModularRoad from an existing road network. But when I ask for .Road it's set to null. Why is it null and/or how should I get to the underlying ERRoad instance? (I want to change the road type).

13. ### Barritico

Joined:
Jun 9, 2017
Posts:
234

Version 3.1.9f3
Unity 2019.2.20f1

14. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi donkey0t,

How are you using the scripting API?

// This creates a reference to an existing road network object in the scene

Thanks,
Raoul

15. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
@Barritico,

In my post I mentioned how this works and what will happen in Scene View in different situations. How does that relate to your situation and what do you see?

Thanks,
Raoul

16. ### donkey0t

Joined:
Oct 23, 2016
Posts:
28
Oh I see new ERRoadNetwork() doesn't create a new network, it grabs the existing one?

17. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Yes, it does that when a road network object already exists in the scene. Otherwise a new road network object will be created.

Thanks,
Raoul

18. ### Barritico

Joined:
Jun 9, 2017
Posts:
234

- I created a road.
- At a certain point I have inserted an I CONNECTOR
- I've done a "build" of the road.
- Then I deleted the I CONNECTOR.
- If I touch anything else, I try to join the points and nothing happens. In the other images I show the "attempt" I make on both roads, without success. And there are no colors or anything.

File size:
2.1 MB
Views:
46
File size:
2.3 MB
Views:
46
File size:
2.3 MB
Views:
45
19. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi Barritico,

Do you mean the road network is in Build Mode and is that where the I Connector is removed? In that case, can you switch back to Edit Mode first?

If you want you can email us the project so we can look at it.

This is what it should look like, the other marker lits up in light blue for matching road types, orange for non matching road types.

Thanks,
Raoul

20. ### LeonaWest

Joined:
Mar 7, 2017
Posts:
7
Hi Raoul,

Unable to bake spotlights and point lights on roads made with EasyRoads3D.
Light and road objects are static.

Unity version:2018.2.20f1

Thanks

21. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi LeonaWest,

Is this only related to spotlights and point lights? Do Directional Lights bake well?

Is this in Build Mode and is "Calculate Lightmap UVs" checked?

Thanks,
Raoul

22. ### LeonaWest

Joined:
Mar 7, 2017
Posts:
7
Hi Raoul,

Directional Lights bake well.
"Calculate Lightmap UVs" is checked and Bake in Build Mode, but spotlights and point lights are not baked.
Errors appear when baking.
Appears when baking Directional Lights.

Thanks

File size:
17.9 KB
Views:
43
23. ### LeonaWest

Joined:
Mar 7, 2017
Posts:
7
PS: The same error appears when baking spotlights and point lights.

24. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Did you say in your previous post that Directional Lights bake well or does that also result in Errors?

Normals are always calculated both in Edit Mode and in Build Mode. Do you do coding? You could do a test by forcing Mesh.RecalculateNormals() on the road mesh. Does that make a difference? Or you can email us the project or a small project where this situation can be reproduced.

I just double checked, in an open project 2018.3.0f2, Directional Lights, Point Lights and Spotlights appear to bake well.

Thanks,
Raoul

25. ### LeonaWest

Joined:
Mar 7, 2017
Posts:
7
The same error message appears when Directional Lights are baked.
However, it is baked well. It is unclear why Directional Lights only works, despite the appearance of the error message.

I can't solve it, so I'll send you a project file that will reproduce the error.
I will send the project file at a later date.

Thanks

raoul likes this.
26. ### LeonaWest

Joined:
Mar 7, 2017
Posts:
7
Hello Raoul,

The baking problem has been resolved.

Because the lightmap size was small, it didn't bake well.
The error was another GameObject issue.

Regards.

27. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi LeonaWest,

Glad to hear you got that resolved and thank you for the update!

Raoul

28. ### eblumrich

Joined:
Nov 12, 2015
Posts:
89
K- perhaps I am missing this part of the manual, but I am having a hard time figuring out how to fine-tune connections, and their relations to the roads with which they connect.

For example- note the following:

The T-Intersection, in this instance, is FAR too wide:

Note how this causes the connecting road on the left to rise WAY above the terrain beneath...

This problem is far more visible, after I build the terrains:

Note how far the road surface/terrain has changed, in relation to the curb.

Any assistance in fixing this would be greatly appreciated!

-Thanks!

29. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi eblumrich,

It is a bit hard to see how the shape of the intersection relates to the shape of the connected roads.

But if the width of the intersection connections and the width of the roads do not match, what is the setup of the T-Intersection? Are the roads based on road types?

General Settings > Road Types > Create New Connection Prefab

This button is available just below the material options. The selected road type will be assigned to the new connection prefab. The Connection material will be used for this prefab. The road width will match and this intersection can be updated automatically when the road type width is changed in a later stage.

Thanks,
Raoul

30. ### PHeimlich

Joined:
Oct 15, 2018
Posts:
4
Hi raoul,

Is it possible to generate narrowing/widening roads? So for example to set for each roadPoint an individual width like in the attached pic? I think it's very import to create realistic roads, for exmaple a motorway exit.

Thanks,
PHeimlich

File size:
130.1 KB
Views:
49
31. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi PHeimlich,

The road shape will gradually adjust to the connection width when the widths do not match. This may already work for the situation in the image.

Otherwise, Shift + N activates options to change the road shape per marker. Handles will be visible for each road shape node. The position can be changed both in Scene View as in the Inspector. That way the road width can be adjusted for specific road section.

In v3.3, there will be more control over this in a way that it is possible to define the road profile, for instance the position of line markings. This makes it easier to change road widths on road sections preserving the width ratios on the edge of the roads so line markings do not change in width.

Thanks,
Raoul

32. ### PHeimlich

Joined:
Oct 15, 2018
Posts:
4

Awesome, thx for your answers! Is it also possible via API? Because I generate the roadNetwork via API.

Thanks,
PHeimlich

33. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
This is not possible through the API at the moment. I will add this for the next update.

Thanks,
Raoul

PHeimlich likes this.
34. ### eblumrich

Joined:
Nov 12, 2015
Posts:
89
Okay- I see that I did not relate my question properly, and perhaps the images I sent did not show exactly what my issue is.

The problem has nothing to do with road WIDTH or road SHAPE.

Rather, it is an issue with the length of the connections in a given connector, and the road splines they create.

Let me show you a simpler, more accurate visual representation of the problem:

The "connections" (the parts in red) are too long- they do not fit my terrain, and when I try to connect roads with them, the image above is how the junction looks, in relation to the terrain - note how the extra-long connection causes the road spline to extend FAR above the terrain.

So- how would I make these connections tighter/shorter so that I can make junctions that conform better to my terrain?

(NOTE: simply building the terrain to conform to the new spline (in green) is not acceptable- the terrain cannot be simply pushed as much as a meter out of position in places, without such requiring a complete re-design of a game world that we've been working on for 2 years..)

Assistance appreciated.

#### Attached Files:

File size:
11.6 KB
Views:
36
Last edited: Feb 20, 2020
35. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Looking at the images you initially posted I see what you mean.

One thing that has an effect on the length of the connections is the corner radius between connections.

Apart from that, the road indeed follows the direction of the connection at the start. This is necessary to guarantee the best possible terrain deformation.

Looking at the road curve relative to the sidewalks which I assume are manually placed or as a separate side object, the angle between the intersection and the sidewalk is rather strong. Aligning the road with the sidewalk will effect terrain deformation unless the terrains heightmapscale is small, smaller then 1.

I belief there is a way to change the way roads attach to crossings, but it will make terrain deformation less reliable that is why it is not available in the editor. I will check this tomorrow and perhaps add it undocumented to the scripting API.

Thanks,
Raoul

36. ### jister

Joined:
Oct 9, 2009
Posts:
1,723
@raoul first off, nice tool! Thanks.
So I need to implement most of it's functionality in runtime.
the creating road part was easy, now i try to add things like: adding a side road to a main road and auto convert 2 overlapping roads to a crossing. I thought i would find my answers in the editor script for ER Modular Base, so i decompiled the Editor DLL, but even in there I am unable to find the code used to, for example, insert a crossing.
Is there any demo that shows more Runtime functionality than the "scene runtime"?

37. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi jister,

Thank you!

We cannot really provide feedback on other methods.

Here are some starting points.

public ERConnection[] GetConnections()
public ERConnection GetConnectionByName(string name)

Then you can either attach crossings directly to the road

public ERConnection AttachToEnd(ERConnection sourceConnection, int connectionIndex)
public ERConnection AttachToStart(ERConnection sourceConnection, int connectionIndex)

Or the crossing can be instantiated in the scene followed by connecting the roads

public ERConnection InstantiateConnection(ERConnection sourceConnection, string name, Vector3 position, Vector3 eulerRotation)

Connect roads to already existing crossing objects

public bool ConnectToStart(ERConnection connectionObject, int connectionIndex)
public bool ConnectToEnd(ERConnection connectionObject, int connectionIndex)

The logic of which connection index to connect to is currently something you have to code. The ERConnection class has for example something like:

public Vector3 GetLocalConnectionPosition(int connectionIndex)

which can be useful to find the nearest crossing connection to a road object.

Thanks,
Raoul

38. ### jister

Joined:
Oct 9, 2009
Posts:
1,723
Hey @raoul
thanks for the quick reaction!
Will try these suggestions and get back to you when I'm stuck if that's ok.

one thing though ERRoad.SplitRoad doesn't seem to exist, but i did find SplitRoadExt...

39. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi Jister,

ERRoad.SplitRoad(int markerIndex) should exist, I just double checked. You want to use this rather then SplitRoadExt as it returns an ERRoad object.

Yes of course, please ask if you have questions!

Thanks,
Raoul

40. ### JonaOneview

Joined:
Nov 3, 2019
Posts:
11
Hi Raoul,
I've been having a problem ever since I switched to working with HDRP in unity 2019.3
I tried opening a fresh project and importing only EasyRoads and the HD package needed for the HDRP shaders and for some reason I can't use the Road Network interface properly. the arrows in the following image are non-interactable, clicking them will not open anything. I can still interact with anything other than these arrows though. I'm not seeing any errors or anything.

41. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi JonaOneview,

The behaviour in the new Unity 2019.3 UI has changed.

Click the text next to the arrow opens/closes the foldout.

Thanks,
Raoul

42. ### JonaOneview

Joined:
Nov 3, 2019
Posts:
11
Wow, I feel kinda dumb now, I didn't even think of that
Thanks Raoul.

43. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Working with 2019.3 for 3 months or so, and I am still clicking the arrow occasionally

Thanks,
Raoul

44. ### jister

Joined:
Oct 9, 2009
Posts:
1,723

an other Question: ERConnection are the "markers" that get created when clicking and a new piece of road gets added, right?
if i create a road with a few clicks and then ask for all connections from the network, the array is 0? So I'm mistaken about what connections are?

edit: nvm, road.GetMarkerPositions() is what i was looking for.

ok last Q (i think)
I need to replicate dragging out a road from a crossing. I would also be ok with the next click after putting the crossing to make a road connected to the nearest free connection on the crossing.
Any hints about how to create a new road that auto attaches to the crossing? I know i can make the road first and then attach it to the crossing, but I'd like it to make a road from the crossing to where the player clicked.

Last edited: Feb 26, 2020
45. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Hi Jister,

I see what you mean, it is indeed missing in the final build. That is fixed in the next update. Thank you very much for reporting this!

ERConnection is a reference to the crossing prefab, the prefabs that can be added in the scene from the 3rd tab from the left when building the road network in the Unityt editor.

There is not something like dragging out a road from a crossing directly through the scriptIng API. But it can be simulated in two steps:

1) Create a new road with two markers, the second marker is positioned where the mouse button is released. The first marker position is at the connection but is probably not so relevant because the road will snap to the crossing in step 2.

2) The start of the road is connected to the specific crossing object to the connectionIndex where the road was dragged out. ERRoad.ConnectToStart(ERConnection connectionObject, int connectionIndex)

Thanks,
Raoul

46. ### jister

Joined:
Oct 9, 2009
Posts:
1,723
ah ok, well that's exactly how i did it.
I do notice that my crossings prefab goes "missing" if i already spawned it once. (so second time i call the api to insert a crossing...)

the piece of relevant code:
Code (CSharp):
1. if (Input.GetMouseButtonDown(1))
2.         {
3.             RaycastHit hit = CameraBase.Ray(false, "Road");
4.             Vector3 point = hit.point;
6.
7.             tree = new KDTree(road.GetMarkerPositions(), 32);
8.             List<int> resultIndices = new List<int>();
9.             query.ClosestPoint(tree, point, resultIndices);
10.
11.             newCrossing = new ERConnection(TCrossing, "Crossing"+crossCount++);
14.             newConnection = road.AttachToEnd(newCrossing);
16.         }
edit: seems that this doesn't return a Connection the second time?
Code (CSharp):
1. newConnection = road.AttachToEnd(newCrossing);

Last edited: Feb 26, 2020
47. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Code (csharp):
1. newCrossing = new ERConnection(TCrossing, "Crossing"+crossCount++);
Where does TCrossing come from?

In any case, the scripting API works in a similar way as the Unity editor functionality. In the Unity editor all available crossing prefabs in /Assets/EasyRoads3D/Resources/dynamic crossings/ and /Assets/EasyRoads3D/Resources/custom crossings/ are collected when selecting the road network object.

These prefabs are then displayed in the 3rd tab from the left in the Inspector, where they can be selected and dropped in the scene (In Unity 2018.3+ it is actually possible to drop the prefab directly in the scene from the project folder).

The scripting API works in a similar way.

In my post yesterday there is:

public ERConnection[] GetConnections()
public ERConnection GetConnectionByName(string name)

That is how to access the available prefabs in the above mentioned folders. This can then be passed in your next line:

Thanks,
Raoul

48. ### jister

Joined:
Oct 9, 2009
Posts:
1,723
@raoul the TCrossing is just a field that holds your default T Crossing prefab.
I got it to work by checking the AttachToEnd function, looks like the second time it doesn't get passed the first condition check

Code (CSharp):
1.  if (this.roadScript.closedTrack || Object.op_Inequality((Object) this.roadScript.startPrefabScript, (Object) null) || Object.op_Inequality((Object) this.roadScript.endPrefabScript, (Object) null) && !this.ConnectionMatch(connectionObject))
2.         return (ERConnection) null;
debugging these values, i got this the first time:
false/null/null/false
which works
second time:
false/Default T Crossing (EasyRoads3Dv3.ERCrossingPrefabs)/null/false
which doesn't work
for now setting
Code (CSharp):
makes it work but seems hacky...?
any idea why it gets this reference the second time?

Last edited: Feb 26, 2020
49. ### raoul

Joined:
Jul 14, 2007
Posts:
4,930
Looking at the code you posted and the further feedback it is hard to comment and get an exact idea of the situation.

If ConnectionMatch() returns false in your code then that means that none of the connections of that prefab has a roadshape that matches that of the involved road.

But that seems unrelated to this:

Code (CSharp):
If that fixes the problem then it appears that a connection was already attached to the start? That is the only situation where road.roadScript.startPrefabScript would not be null initially. Or the start connection does not match the end connection and therefor ConnectionMatch() returns false.

Why don't you simply pass TCrossing if that is a reference to the prefab in project folder?

Thanks,
Raoul

Last edited: Feb 26, 2020
50. ### JonaOneview

Joined:
Nov 3, 2019
Posts:
11
Raoul I seem to have a weird problem in Unity 2019.3
Whenever I choose a road beginning\end node and create a connection attached to it the connection prefab appears outside of the EasyRoads Network (as in, in the scene with no parent object)
I think this might be because of a problem I have with the crossing prefabs, but do you have any idea what might cause this behaviour?
This is also causing a lot of errors unless I put the crossing into the connection objects parent:

File size:
198.1 KB
Views:
25
unityunity