#### Search Unity

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

1. ### econt

Joined:
Apr 8, 2019
Posts:
43
Hi,
I have a question. - I am using the scene runtime and would like to know how I can rotate the cube, which is following the road, so that it is facing forward and changing it's rotation automaticly. - How could this be done?

2. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi econt,

That can be done in a similar way to get the position using

public Vector3 GetLookatSmooth(float distance, int currentElement)

V3.2 will have a lot more options to get data for ai purposes. For example lane info for both roads and crossings.

The example script used for the video is part of the beta.

Thanks,
Raoul

Flavelius and hopeful like this.
3. ### econt

Joined:
Apr 8, 2019
Posts:
43
thanks for the fast reply. - I have read out the look vector3, but the how can I convert the Vector3 to a quarternion? - go.transform.rotation of the cube should be a quarternion as I understand. (please see last row)

float deltaT = Time.deltaTime;
float rSpeed = (deltaT * speed);

distance += rSpeed;
// pass the current distance to get the position on the road
Vector3 v = road.GetPosition(distance, ref currentElement);
v.y += 1;

go.transform.position = v;
go.transform.rotation = _lookVector;
}

4. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
That depends on what you want to do and what your roads look like. If no tilting is involved you could try:

go.transform.forward = _lookVector;

Thanks,
Raoul

5. ### colin_young

Joined:
Jun 1, 2017
Posts:
128
That kind of makes sense, but when I looked at the definitions for the 2 road types, both were Primary. I have a T-crossing with (going clockwise):
• Road type C (secondary - on the T)
A-B is the straight-through. Is this scenario not supported? If not, I can probably take care of it by using type B on both sides and just turning off the side objects on the 'A' side. This particular crossing has been giving me a lot of grief. I was attempting to replace a non-functioning crossing when I ran into this problem. The original one I created had somehow lost the connection on the B side and I was unable to connect that road. When I dragged it over the crossing, I got a red circle and the original crossing was also no longer showing connector handles (the little green spheres), but it was still showing 3 connections in the inspector panel.

Also, a suggestion to make it easier to work with flex connectors: some sort of indicator on the connections, maybe a number floating over the handle, to make it easier to match up "connection 1" in the inspector panel with the connection in the GUI would make things much easier to keep track of, especially if the crossing has been rotated.

6. ### econt

Joined:
Apr 8, 2019
Posts:
43
yes that's it. - I wanted to use the camera as go and simulate a car driving along the spline. - thank you

about the new AI features are they already implanted and are there tutorials or examples already available?

7. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Colin,

Are A and B indeed also different road types, so all 3 roads are different road types? That is currently not supported. What should this look like? What type of roads are involved?

The road types in the Flex Connector Inspector are the road types that will be used to create the Flex Connector. If the Road shapes match, an option is to create the Flex Connector with A C A road types and connect the actual road type B road to the road type A connection.

The Flex Connector Inspector shows all connected roads starting with "Road X" where x is 1,2,3, etc. In the Scene View window a label with the same "Road X" is displayed in the center where the road connects. Isn't that what you are asking for?

Thanks,
Raoul

8. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi econt,

The v3.2 betas are available in the download section on our website. Please send an email with your order id if you do not have access yet. This is beta, it is not documented in the manual yet, but the video in my previous post above shows how to set lane info for road types and how to customize lane data on crossings. The script that was used at the end of the video is part of the beta package.

Thanks,
Raoul

9. ### colin_young

Joined:
Jun 1, 2017
Posts:
128
In this case A and B are the "same" road except that one has side objects, the other does not. So for this situation it seems the easy solution is to just have one type and turn the side objects on/off as necessary. That will also simplify management of my road types. It also may explain why I could not drag the road onto the original connection, but not why I was allowed to create this situation in the first place.

I have noticed some "random" road X labels floating around my scene, but I never realized the relationship was between the flex connector and the labels, probably because they are not located anywhere near the connections. I'll try to grab a screenshot of that this evening. But yes, that's exactly what I was suggesting, assuming they actually appear near the associated connection.

10. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Yes, but you can also set road Type B for the 3rd connection to road type A, that is on the Flex Connector only. The attached road can still be of type B if the shape is the same.

These labels are located in the middle of the connections when the Flex Connector is selected. When the Flex Connector is not selected the blue marker handle of the attached road is visible at the same position.

Thanks,
Raoul

11. ### colin_young

Joined:
Jun 1, 2017
Posts:
128
I'm seeing the labels floating in the scene. There is no relation to the crossing that I can see. It's like they are on a different plane that moves when the camera moves, but isn't fixed to either the camera or the terrain:

12. ### econt

Joined:
Apr 8, 2019
Posts:
43
Hi Raoul,

thanks for the fast reply. - I would like to place decals with script along the road. Is there a command in the API to do that? - Or what solution would you suggest?

13. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Colin,

That is strange. It seems that the relative position between the labels is correct. Is the center of the Flex Connector located at the pivot point, the game object position? Is this always the case? Also in the demo scene? I will see if this can be recreated some how?

Thanks,
Raoul

14. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi econt,

That can be done with the side object system. In the Side Object Manager (2nd tab from the right) the Mesh type of side object is required for this. The distance between decals can be set with several controle to randomize this. The demo package includes procedural decal side objects example like lane markings. A similar material can be used. The HD Roads package includes examples of both.

Thanks,
Raoul

15. ### econt

Joined:
Apr 8, 2019
Posts:
43
Hi Raoul,

I want the decals and sideobjects with script (not manual). - Is there a command in the API? - Do you have a code example?

16. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Side objects are generated automatically not manually, they only have to be activated for the specific road. As from v3.1.8 this can be done through the scripting API.

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

returns the object of type SideObject

activates / deactivates the side object for this road object

ERRoad.SideObjectMarkerSetActive(SideObject obj, int markerIndex, bool value)
activates / deactivates the side object for the passed marker index for this road object

ERRoad.SideObjectMarkerSetActive(SideObject obj, int[] markerIndexes, bool value)
activates / deactivates the side object for the passed array of marker indexes for this road object

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

And they can also be activated for road types so new roads of that type have these decals automatically added.

The other way is that you use the road spline data and build something similar yourself. ERRoad.GetSplinePointsCenter() returns an array of Vector3 with the road shape.

Thanks,
Raoul

17. ### colin_young

Joined:
Jun 1, 2017
Posts:
128
AFAIK the pivot point and flex connector are at the same location.

• Created a new project in 2019.1.12f1
• added a terrain (default, unchanged from flat)
• Labels in wrong places
• Labels in wrong places
• OS X 10.13.6
• Using integrated Intel HD 4000 graphics

18. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Colin,

We insert new Flex Connectors by starting new roads from other roads, this auto inserts the Flex Connector. But I just tested creating a Flex Connectors from an X-crossing, that also shows the label at the connection center.

Does the same happen in the v3.2 beta demo scene? Both for Flex Connectors already in the scene as for new connectors.

Thanks,
Raoul

19. ### colin_young

Joined:
Jun 1, 2017
Posts:
128
The only sample scene I have with 3.2.b6 is the AI traffic scene, and that is showing the same problem, both with existing connectors and if I add a new one (by dragging from an existing road).

20. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi,

That is strange. It looks as if the label positions are somehow scaled. What is involved here is Camera.WorldToScreenPoint(), the SceneView window height and the size of the label, GUI.skin.label.CalcSize().

I will see if I can find out more info based on the specs in your previous post.

This is where the three labels should be

Thanks,
Raoul

21. ### brichard0625

Joined:
Dec 18, 2016
Posts:
26

Can someone help. Everytime I build a simple road. It keeps coming out like this. Is there anyway to prevent this from happening. I have tried everything but it doesn't seem to corrent the issue. If I raise the terrain or adjust it, it just keeps happening no matter how I edit it.

22. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi brichard0625,

What are the terrain specs, heightmap resolution and terrain size? The roads looks fairly bumpy, there must be enough terrain points available to adjust the terrain to the road shape.

Other then that, what is the Raise Level in Build mode in the Inspector? And which shader do you use? The EasyRoads3D shaders have an Offset option to deal with z fighting with the terrain. The alternative is the Raise option, or, in the v3.2 betas, use a road shape with thickness.

Thanks,
Raoul

Last edited: Aug 4, 2019
JBR-games likes this.
23. ### brichard0625

Joined:
Dec 18, 2016
Posts:
26

Raise Level 0, If I Use a raise level, then the road is above the terrain, How do you raise the level and still have it build level with the terrain. Im using a supplied shader by easy roads. If I use a raise level of .2, everything looks fine but you can see where the road and the terrain don't meet.

Last edited: Aug 5, 2019
24. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265

Size 1024 and heightmap resolution 257. That is about 4 units per terrain cell. It also depends a little bit on the scaling in your first screenshot but this is not a super detailed terrain. For example the default Unity terrain object has size 500, heightmap 513, about 1 unit per terrain cell. Try experimenting with this with a road in a hilly terrain and see the different results.

But that is only with respect to the left side of your image, the bump. For the other flat areas, please check my other comments regarding the Raise option, EasyRoads3D shader offset options and possibly the v3.2 customizable road shape feature for roads with thickness to deal with z-fighting. This is noticeable in the image as well.

Thanks,
Raoul

25. ### stinaflodstrom

Joined:
Jan 20, 2017
Posts:
1
Can the tool automatically insert crossings when importing OSM data?

26. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hello stinaflodstrom,

Real world situation can be quite complex there for inserting crossings is currently not possible yet.

Inserting standard X, T crossings is implemented but not activated at the moment. V3.2 will have more built-in crossing options, the Flex Connector for flexible angles and motorway on/off ramps. Once that is all available we will also continue with support for auto inserting crossing for OSM data.

Thanks,
Raoul

27. ### unity_juSh8cHLxX7reg

Joined:
Jun 20, 2019
Posts:
2
Hi raoul.

I'm having trouble with the Custom Crossing tool.
Most of the times the tool cannot create a road connection. When selecting two vertices, it only takes in count one of them.

Increasing the vertices or decreasing has no effect :/

28. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi unity_juSh8cHLxX7reg,

Which version are you using?

v3.1.8 had an issue that sometimes resulted in what you describe. v3.1.8.f2 was released earlier this week, it includes a fix for this. Does that indeed work?

Thanks,
Raoul

29. ### unity_juSh8cHLxX7reg

Joined:
Jun 20, 2019
Posts:
2
It seems to be fixed now. Thanks!

hopeful and raoul like this.
30. ### PhilipZ0

Joined:
Mar 5, 2019
Posts:
16
Hey Raoul,

is it possible to create a curvy road dynamically from the data ["lane_curve":0.000595953,
"lane_width":4.53].

The vehicle drives and gets data about the road ahead and updating the markers or something to achieve the generation of the road ahead. If that is possible could you write small code idea to pursue using your API? Should I generate spline and then update the markers accordingly? Thank you!

31. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi PhilipZ0,

Generating roads at runtime through the scripting works similar as in the Unity editor, by adding markers as control points. Through the scripting API:

or

Thanks,
Raoul

32. ### tanu1215

Joined:
Feb 8, 2016
Posts:
6
Hi.

I am developing an RTS and I want my player-controlled, yet still AI, vehicles to follow waypoints along the road. To generate these, is it simply GetSplinePointsCenter() + an offset for correct lane positions?

33. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi tanu1215,

Yes, that is how waypoints can be generated.

Also, V3.2, available in betas on our website, includes options to set lane info for road types and matching lane data on crossings with a script example how this can be used.

Thanks,
Raoul

34. ### tanu1215

Joined:
Feb 8, 2016
Posts:
6
I just imported the beta to my project, and although I haven't really done much work with it yet, it looks promising. I am using Intelligent Traffic Systems for my ambient traffic. If I understand, I'll be able to auto-generate lanes and what not using the road data? Interesting, this will make it extremely easy to create lanes then!

35. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi tanu1215,

Yes, the number of lanes can be set for each road road type. Lane data will be generated for all roads and crossings based on that road type. The runtime script example shows how to access this data. It can be used directly by a traffic system or it can be used to generate waypoints.

Thanks,
Raoul

IsDon likes this.
36. ### Mindan

Joined:
Jul 10, 2015
Posts:
2
Hi, we don´t know if this is possible to fix this, but our team is having a problem with non uniform connectors. UVs seem to broke if we scale one side of the connector, this is necessary to our project and we don´t know how to fix it. Any help will be preciated.

37. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Mindan,

1) I Need this to be custom

"Primary Road" is selected as the road type for that connection. The connection will inherit the settings of the "Primary Road" road type. There for "Connection Width" is greyed out. Assigning road types to crossing connections is the recommended workflow. If you decide to, for example, change the road width at a later stage, you can do that for the specific road type. All roads and crossings in the scene will auto update after pressing the "Update Scene Instances" button near the bottom in the road type settings.

2) But UVs Get broken and lines don't fit.

The position of the outer line can be controlled through the "Inner Segment Distance" slider near the bottom in "Corner Settings" visible in your image. However if the same texture is used as the one for the more narrow road the lane width will still be wider because the road is wider, the texture will stretch.

V3.2, available in betas has additional options to define the road profile and lane positions. Together with the new Flex Connector this gives more control for crossings involving different road types.

Thanks,
Raoul

Mindan likes this.
38. ### Mindan

Joined:
Jul 10, 2015
Posts:
2

Thank you
I´ll search for the solutions you provide

39. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Additionally, if you want to use the same texture for both roads, the geometry must be more complex, vertices at the left and right side of the lines s the UVs can be set accurately. This can be done in v3.2.

Alternatively you could consider adding the line markings as side objects relative to the left and right side of the road edges. The same line side object can be used for both road types. Both the HD Roads package as the demo package includes examples of this. Adding these lines to crossings, if required, is more complicated at the moment. They could be added as separate decals to the crossings.

Thanks,
Raoul

40. ### midgear

Joined:
Apr 5, 2013
Posts:
9
So I'm trying to make a basic crossing but I can't save it because the save function is gone. Did the way to save this change or is the a bug?

41. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi midgear,

Which version of Unity do you use?

In Unity 2018.3+, instead of dropping crossing prefabs in the Scene View window, they can be edited through the Prefab Editor system introduced in Unity 2018.3, the "Open Prefab" button in the Inspector after selecting the prefab in the project folder. Changes will save automatically.

Otherwise, for previous Unity versions the save option is for source prefabs stored in the project folder only. Is that the case?

Thanks,
Raoul

Last edited: Aug 15, 2019
42. ### midgear

Joined:
Apr 5, 2013
Posts:
9
Ah thank you so much this was driving me nuts!

raoul likes this.
43. ### Flavelius

Joined:
Jul 8, 2012
Posts:
779
Hi, i recently purchased this nice tool.
While using it i stumbled upon a few oddities though i can't explain, maybe you can help me there (using the newest asset store version, unity 2019.2.0f1).
The first thing is that it seems one of my roads lost its type at some point, not sure when and how (maybe it could help if it let me reselect it):

The second thing; The road types of the ER-prefab editor don't seem to be linked to the ones on the Road Network, but if i create one in the prefab editor it shows up in the RN:

For the connection editor the documentation could be improved as well, it took me a few tries to notice that the vertex selection is automatically assigned to the connection and not that i had to select them first and then click add connection to make the selection the new connection (but it makes sense the way you do it ofcourse, just the documentation that wasn't very clear).
Also, changing for example UV-tiling in one of the road types and clicking 'Update Road Type' didn't seem to propagate the change to the objects in the scene, even 'Refresh Road Network' didn't update them.
Then, sometimes, depending on the angle of the viewport camera i'm not able to select the gizmos, in this example, after i selected the right one, i couldn't click the left ones anymore (reproducable), only after i completely deselected the RN and reselected the wanted parts:

Lastly, more a question i couldn't find an answer to; what is this white sphere (right) meant for (i can kind of select it, it toggles between big and small/opaque and transparent, but it doesn't seem to affect anything) ?

P.S. i also noticed that when using custom road meshes the merge border of crossing<->road sometimes doesn't look correct shading-wise when they contain smoothgroups/split vertices/hard shading (sorry no picture, forgot to take one). I guess that's because it may merge the wrong verts of each part when in this case they are in exactly the same position because of their hard-shading-split-vert-doubling. The solution was to use complete vertex/smooth shading and manually champfer/create creases (/bevels) to aid the shading; maybe this could be hinted in the docs as well.

Last edited: Aug 15, 2019
44. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Flavelius,

The system works in a way that roads and crossings can only connect if the shape matches, this is especially required in v3.2 where custom road shapes are built-in and supported. Custom shapes are already possible through the Custom Prefab system, connections based on imported models. When a road is connected to crossings the road type dropdown will only show road types matching the shape of the currently selected road type. Sometimes this does not update accuyrately. Deselecting and reselecting the road should fix that. The road probably didn't lose its type.

The Road Type editor prefab shows all available road types in a project. The road types available for a Road Network in a specific scene can be managed in: General Settings > Road Types.

This is useful if you have a large number of road types in a project for different environments / scenes but you only need a few per scene. It makes selecting the road types for new roads easier.

Is this Custom Prefab editor related? This is what is currently in the manual:
-------------------------------------------------------------------------
8. Click Build Connection Prefab. This will create the new custom crossing prefab in the folder /Assets/EasyRoads3D/Resources/custom prefabs
9. Click Add Connection to add new connection info. The next step is to assign the vertices that will connect to roads attached to this connection. This is done by drawing a rectangle (shift + click + drag) around these vertices holding the Shift key. For complex meshes you can use Stage Rotation so the required vertices fit nicely inside the rectangle. The selected vertices will be highlighted in green.
-------------------------------------------------------------------------

Indeed after step 8 it is not necessary to press "Add Connection", the first connection is already added automatically, this was initially not the case. I updated the manual with this info. But defining a connection on your model works as described above. Draw a rectangle around the vertices / nodes that should be part of the connection through Shift + Click + Drag

.

Is this in the Road Type editor? "Update Scene Instances", near the bottom in the Road Types section, should update all the roads in the scene using that road type. I will test this for the tiling option.

Selection issues are unknown. How is this reproducable? Does this happen on every prefab, also the built-in dynamic X and T Crossing examples? Does this happen on a specific cam angle?

When this sphere is toggled on, the crossing will auto rotate in the direction of the connect road. This is noticeable when moving the second last marker or the second marker if it is attached to the first marker.

Thanks,
Raoul

45. ### Flavelius

Joined:
Jul 8, 2012
Posts:
779
As for the road types, maybe it helps if the places where they can be created and selected are somehow marked as being local or project-wide. Even after reading your explanation, which sounds reasonable, i can't still match it completely based on what certain dropdowns i expect to represent in scope. The connection prefab editor in my understanding should display project wide road types as it creates assets, which i expect to be in global scope (maybe i'm misunderstanding that), but it doesn't seem so. The road network has buttons to add project road types and road types, maybe those 'road types' everywhere should be prefixed with local or network too, as it's possible to create equally named road types (in different scopes) that are then placed in the same dropdown.
And yes, the missing road type reappeared, but only after a unity-restart though.
Also, yes the add connection thing was just a little confusing as the first connection was already precreated.
The rest was in the reproduction scene you received. Thanks for the fast reply there.

46. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Flavius,

Maybe I misunderstood your initial question about this in your previous post. The road types dropdown question seems to be related to the dropdown in the Custom Prefab Editor window, crossings based on imported mesh models.

An essential part of road types is the road shape setup, the position and number of vertices / nodes. The Road Type dropdown in the Custom prefab Editor window will be populated with available road types matching the profile of the selected connection. If the connection has a "standard" two node setup, road types created in "General Settings > Road Types" will also be listed.

However, the current public v3 built-in road types have a two node setup, one vertex on the left, one on the right. Connections on imported meshes can be more complex with more then two nodes. This sort of road types cannot be created in v3.1 through General Settings > Road Types, hence why the Custom prefab Editor window includes a "New Road Type" button as well. That way the shape of the selected connection will be stored correctly.

v3.2 will support built-in custom road shapes, so more complex road shapes can be created through "General Settings > Road Types" as well.

This can be recreated in the scene you sent and after trying some things, it seems actually be related to the same actions, instantly selecting markers of different roads. When first selecting road "Otherlane", then instantly selecting the other "Otherlane" road (not "Third Road") the road type dropdown is empty. After deselecting by clicking on the terrain and reselecting the road, the road type is visible in the dropdown.

Any Custom Connection prefab will have at least one connection, that is why the first connection is already prepared which was added in a later v3.1.x update. The online manual is already updated, "Add Connection" is now mentioned later when creating the next connections.

Yes, as already mentioned in the other conversation, the problem on our end is not so much cam angle related, it is related to the first marker of road "Third Road" being selected. We will look into that, but, as you already mentioned, deselecting the road fixes the problem.

Thanks,
Raoul

Last edited: Aug 16, 2019
47. ### ThendonExe

Joined:
Feb 27, 2019
Posts:
1
Hey raoul,

I have some questions about the Plugin. I am working with the 3.2 beta.
1. We are trying to place an independent fence with snap-to-terrain on the landscape. After building the terrain the fence keeps being attached to the unaltered version of the terrain. Is there an option to snap independent sideobject "roads" to the final terrain version?
2. Is it possible to reduce indent to 0? I think its minimal value is locked to the default indent which also can't be set lower than 3.75f or something like that.

Thendon

48. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Thendon,

Objects marked as "Side Object" not involving a road will auto snap to the terrain, but this is more marker / Edit Mode related. Is "Snap to Terrain" in the Side Object Manager toggled on for this side object? That should update the side object to the adjusted terrain in Build Mode.

Otherwise, is the terrain adjusted according the full road network or only according the selected road object(s)?

There must be enough terrain points available to adjust the terrain in the most accurate way to the road network and it is impossible to add detail points to the terrain heightmap. There for the Indent values are locked to the minimum value required by the terrain in the scene. This is based on the terrains heightmap resolution and size. In your case it results in a minimum required value of 3.75f. There is a way to set this minimum required value to 0, but terrain deformation will become unreliable.

Thanks,
Raoul

49. ### colin_young

Joined:
Jun 1, 2017
Posts:
128
With the current 3.2 beta, is there a recommended workflow to add curbs when working with flex connectors? Or, is there a way to convert flex connectors to custom connectors (i.e. a fixed mesh), that could then be edited manually?

50. ### raoul

Joined:
Jul 14, 2007
Posts:
5,265
Hi Colin,

That is currently not yet supported on the Flex Connector. Curbs / sidewalks will get an upgrade in v3.2 as well which is necessary to deal with possible small corner angles on Flex Connectors regardless the texture type (preserving tile patterns etc.).

To some extend this can currently be done as part of the road shape itself. Road shapes can be customized in v3.2, the curb can be part of the road shape also on Flex Connectors. Whether that will look good depends on the curb texture, especially on sharper angles.

There is currently no built-in option to export a Flex Connector, but there are several free .obj export scripts available that could be used for this.