Three things in this post….
The first is how to connect an analogue interface to Unreal using Arduino and Serial data
The second is a hacky method to get google 3d map data into unreal
The third is how to make a boat in Unreal
1. Method to connect analogue interfaces to Unreal using an Arduino connected to USB. Assumes some familiarity with Unreal and Arduino
This is a good first step to hook up the raft tiller to Unreal.
First bit:
Serial data into Unreal from an Arduino over a USB.
(For nerds what’s the difference between serial, COM and USB?)
Works with Unreal 5.1.1 and Arduino NANO – but can be extended to other Arduino’s and versions of Unreal.
(Note to self: I’ve got the ELegoo NANO with ATmega328P and CH340 chips –the reason I’m not using my previous OSC method is that I can’t seem to set the Arduino’s OSC data port for sending data out. – Will try and figure this out – it’s me being stupid, I guess)
Arduino
Here’s simple code (or ‘sketch’ in Arduino speak):
/*Changes LED brightness based on pot
* Created by ArduinoGetStarted.com
* This example code is in the public domain
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-potentiometer-fade-led
*/
int LED_PIN = 3; // the PWM pin the LED is attached to
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// declare LED pin to be an output:
pinMode(LED_PIN, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// reads the input on analog pin A0 (value between 0 and 1023)
int analogValue = analogRead(A0);
// scales it to brightness (value between 0 and 255)
int brightness = map(analogValue, 0, 1023, 0, 255);
// sets the brightness LED that connects to pin 3
analogWrite(LED_PIN, brightness);
Serial.println(brightness); // print the value
delay(50);
}However I ended up using slightly fancier code which is here: it is doing some work to eliminate errors at the far end of the pot. It’s converting the values to a percentage that it sendings out over serial.
// converts the position of a 10k lin(B) pot to 0-100%
// pot connected to A0, 5volt and ground
// --Bruno however im using a rotary pot 20k
// Double-read of value is added to eliminate crosstalk (if more than one analogue input), or if a pot value >10k is used.
// Deadband is used for the ends to elimite lots of 0 values at the ends
int rawValue;
int oldValue;
int LED_PIN = 3; // the PWM pin the LED is attached to
byte potPercentage;
byte oldPercentage;
void setup() {
Serial.begin(9600); // set serial monitor to this baud rate, or change the value
}
void loop() {
// read input twice
rawValue = analogRead(A0);
rawValue = analogRead(A0); // double read
// ignore bad hop-on region of a pot by removing 8 values at both extremes
rawValue = constrain(rawValue, 8, 1015);
// add some deadband
if (rawValue < (oldValue - 4) || rawValue > (oldValue + 4)) {
oldValue = rawValue;
// convert to percentage
potPercentage = map(oldValue, 8, 1008, 0, 100);
// Only print if %value changes
if (oldPercentage != potPercentage) {
// Serial.print("Pot percentage is: ");
Serial.println(potPercentage);
//Serial.println(" %");
oldPercentage = potPercentage;
}
// scales it to brightness (value between 0 and 255)
int brightness = map(potPercentage, 0, 100, 0, 255);
// sets the brightness LED that connects to pin 3
analogWrite(LED_PIN, brightness);
}
}

In this example, if you wire up the Arduino like the diagram above and upload the code (sketch) then turning the rotary potentiometer affects the LED brightness – and the values can be seen as numbers in Arduino IDE’s Serial Monitor.
Make a note of the COM port the Arduino is on – this is our serial port that we need later. Unplugging and replugging the USB lead may change the COM port, so watch for that.

Note if the Arduino IDE is running, Unreal won’t get any serial data; you’ll need to close it first.
Over in Unreal, we need to download and install a plugin called Unreal Engine Serial Communication Port from here. This gets the serial data from the Arduino. Install instructions are included in the zip. It needs to be added to the project’s plugins. I’ve made a simple Actor Blueprint and added a Spotlight component to it, and dropped it in the level.

Then inside the Blueprint, we first do this:

First, we open a serial port, then we check to see if it’s open, then we make a reference to the returned port, ‘Arduino Serial Port,’ and save it for later. (Later on, we will have to remove the PrintStrings -they are here now for debugging)

Here’s the main bit-we read the serial line and print it, then we map its range to the brightness ranges of the spotlight and use that value to set the spot intensity.

The last thing is the get the reference to the serial port and close it when play stops. Arduino won’t connect again if you close the project without closing the port.
The next steps are to test it. Again make sure the Arduino IDE isn’t open when you test this.

Note
This tutorial is based on this useful video here (which is for Unreal 4.2 with an older version of the Unreal plugin.)
Next steps
The next thing to try is with is replacing the rotary pot with a rotary encoder – this is because mechanically, the rotary pot only has a certain amount of turn. It is possible that the physical installation might cause the pot to initialise in the wrong orientation or something. https://www.diyengineers.com/2021/06/03/arduino-rotary-encoder-how-to-use/
2. Map data into Unreal methods…

Method 1
Blender OSM and Terrain for Blender -documentation here
this gives low res data, buildings are cubes bascially
Method 2
Google Earth / 3d Street View method (it’s long-winded though)
needs exactly:
Chrome browser
RenderDoc v1.13
Blender 2.93
Maps Models Importer – Blender Add-On (but version 0.4 where is that? (Bruno has a copy))
I tried many times to get this to work with different versions of software – only these versions worked. May be because of the one thing – moving the 3d view around when capturing the 3d mesh. See this video below for method or this guide on github
Scripty bits you need
set RENDERDOC_HOOK_EGL=0
"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-gpu-sandbox --gpu-startup-dialogOR if you have a 32-bit Chrome
set RENDERDOC_HOOK_EGL=0
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-gpu-sandbox --gpu-startup-dialogAlso might want to try this Lily Capture Merger to stitch the models.
The problem with this method is it makes 1 zillion models and textures which will not work well in Unreal, the textures need stitching. So there is this (well-indexed) video about the whole process below which includes the blender processing using Meshlab as part of a method to make 1 texture material. Best idea is to watch on youtube ((not here)) to be able to find the right times.
Also this vid has the code you will need in its more info part (on Youtube)
However!
There is a better way using this other Blender Add-on Lily Texture Packer & this works extremely well see video.
My method in Blender for multiple parts
First I used Renderdoc to make a few map captures, then I go into Blender to clean up the models.
1. In Blender, make a collection.
2. Import the captured map file (.rdc) to the collection
3. SAVE
Repeat 1-3 for each .rdc file.
4. Use the Lily Capture Merger to rotate and move each part.
(With 10 different .rdc files some came out at odd scales so I had to manually scale and move them and then remove overlapping parts. This was easier if I had the problem parts vertically separated and used the blender restiction toggles to make collections unselectable (locked.)

5. With the complete map arranged, I looked in the top view. Selecting square sections of tiles, R-Click choose Move To Collection. Each of the many bits of the .rdc file has its own texture. To make one texture for a big section is more efficient. So this way I get the map into roughly equal area parts, so that when I make single textures, they have a similar resolution and size.

6. Choose all of one section and use Lily Texture Packer to make one texture.
7. With everything still selected hit Ctrl-L to link materials, then Ctrl-J to join the meshes into 1 mesh, (with the one texture).
8. In the Image Editor window choose the LilyPackedimage and Save it as a jpeg.
9. rename the file parts as something useful like Tile01, Tile01Mat, Tile01Texture.jpeg

10. TAB into edit mode, A to select all and M to merge by distance to remove overlapping verts.
11. Save at each step.
Method 3 -drone data
This is another similar method a bit older i cant embed the youtube here so this is a link
3. Boat in Unreal

Terrain notes
So the landscape is big. 15km wide. Very big. Each landscape texel is 1m so a lowish resolution, especially on the banks. So we maybe have to get better method…
Need to look at World Partition
Virtual Height Field Mesh
