Free Roam Racer Prototype

I have successfully moved the AI to cpp. However it broke the behavior tree debugger/visualizer - the tree works but the visualizer doesn’t.

The blue car is driving by cpp

I have also been bitten by the “child blueprints get their values reset” bug, it affected my procedural roads, so I’ll have to move the remaining parts to cpp ASAP.

I experimented with a parametrized material for buildings and discovered the phenomenon of moire.

Next week, next post. (In a week, it’ll be three months since I started!)

Changed anti aliasing from Temporal AA to FXAA. It got rid of the ghosting, but I think it gives worse aliasing in general.

Ported the remaining road tools to cpp to avoid blueprint bugs.

Made a first 3D model, a simple fence, but haven’t actually used it yet.

I had a brainwave and used the arrow component to visualize angles.
However, getting the components to actually have the scale and color I set requires forcing a rerun of the construction script, otherwise they are red at scale 1 - any ideas why is that so? Blueprints vs cpp make no difference.

This angle visualizing allowed me to fix the angle checking (I was checking the wrong angle) and from that, I wrote turn smoothing code in cpp that actually works.

It works like that:
if angle less than 100 degrees
if spline point 2, add a point at 3
calculate the offset at 3 needed for the angle at 2 to be 100 degrees
offset 3 by the value calculated
PROFIT!

else if spline point last-2, add a point at last-2 (I know it seems counter intuitive, but it effectively adds a point before our point)
do the same calculations as before

Someone on Unreal Slackers alerted me to the fact that most of the lag with grid manager came from the fact the editor was showing all the data. So I ported it to cpp, as well as the crossings creator. An added bonus, instead of a tangle of nodes, setting a bool on the struct in the array is just a single line of code.

So the project that was originally supposed to be 100% blueprints is now closer to 10% blueprints/90% cpp. The things that happen…

good thread, enjoyed reading the details on how you optimized the project

Thanks for posting! People reading the thread means a lot to me! And I hope my findings are useful for others.

Three months since the start!

I transitioned to using the cpp crossings creator for the roads. Also made it possible to specify world space crossing position, which allowed me to quickly recreate the road system in spite of the fact that the grid now has 100x100 tiles instead of 200x200 (so the grid coords are necessarily different)

Spent most of the week trying to figure out how to avoid overlapping textures on sharp turns (which was the main reason I had all that turn smoothing code).

Attempt one was changing the tiling of the road on the turn. Took me a day and didn’t achieve the result, so I binned it.

Attempt two involved @Koderz’s Runtime Mesh Component plugin and was therefore done in a spare project. The plugin does what the name suggests, lets you specify vertices and UVs and whatnots and create meshes on the fly, procedurally. Later you can export them to static meshes and back.

It took me a day to learn how to use the plugin (turns out the order you give the vertices in is very important), another day to get something that mostly worked, but suffered from the same rotation problems on sharp turns as the sidewalks in the original project did. On day 3, someone on Unreal Slackers Discord suggested I use two splines (left edge and right edge) and find the centerline via code. The suggestion was golden, as I had a working solution within hours.

A 74 degree angle proof of concept - with the default UE4 way of doing meshes on splines, overlapping textures would happen at around 100 degrees

Design: The left and right edge are handplaced. The code generates quads at the edges, always 100 uu wide. The remaining part of the road is one big quad. Therefore for every spline point, there are three quads (left edge, middle, right edge) and three textures (left edge, middle, right edge). I had to resort to such tricks to avoid textures stretching badly at angles. The upside is, I could easily swap textures to have e.g. the edge line on the right be different from the one on the left, if I wanted.

i make hover Ai chk this

Project on hold because I’m having weird issues compiling cpp with RMC, so I can’t replicate the proof of concept road in the main project :frowning: