Control UE through OSC
Last updated
Last updated
You can use OSC to do many things. We are going to create a layer in Live FX and use it to drive our Sun in Unreal Engine.
Live FX currently has one way of using OSC that uses the first layer's Canvas transform controls, to control custom properties in Unreal Engine via a blueprint the user can set up.
There are a total of 8 float values that can be used in Unreal Engine, they correspond to the following properties in the Canvas menu (of the top dummy layer).
The numbers here correspond to the Index numbers in the Get OSC Message Float At Index node in Unreal Engine:
You can set these numbers to control many different areas of your Unreal Engine Scene, but for us, the default settings we will use will be to reserve 0 for Sky Light Intensity and we'll reserve 5,6,7 for Intensity and location in the sky:
0: Sky Light Intensity 5: Directional Light Intensity 6: Directional Light Pitch 7: Directional Light Roll
Go to Live FX Menu>Live Links
Turn on OSC Sender
Turn On, enable Animation and press connect.
For your ip, if it's the local machine, you can use 127.0.0.1. For port, you can use 9003 or whatever port, but you'll need to remember this for later.
Create a new layer, and make sure it is the very top layer. This will be a "dummy" layer, do not add color grading or anything else to it.
You can find the whole blueprint here, copy and paste it into your Level Blueprint, and then connect the Event Begin Play to the Create OSC Server Exec pin. It may have some errors, but you should be able to fix them by following the instructions below.
https://blueprintue.com/blueprint/m6-a4t3l/
Here is another pastebin with a few more things added, that will serve as a template of sorts, for OSC.
https://blueprintue.com/blueprint/hpe6xzd2/
Manual Instructions for creating the Blueprint.
In your Level Blueprint (or you could create a new one), from Event Begin Play, add the node Create OSCServer. 1. For the IP Address you can use 0.0.0.0. 2. For the Port use 9003 or whatever you set in Live FX 3. Check Start Listening 4. Write the same Server Name you added in Live FX for the Server Name.
Drag off of the Return Value pin and Promote to Variable and (optionally) rename the variable to OSCServer.
Then add Unbind All Events from On Osc Bundle Received and then add Bind Event to On Osc Message Received.
Drag off the Event socket, type Create Event. Then in the dropdown select Create a matching event.
Rename the event to OSCMessageReceived and press Compile Blueprint.
Drag off the Message pin and promote to a variable. The default name will be Message, we'll keep it the same for now.
Drag off that node and Get OSC Message Float at Index, do this three times. For the Index, we'll use 5,6 and 7.
From the left-side, drag over the Message Variable and select Get Message.
From that variable, connect it to the three Get OSC Message Float At Index.
Draf off the execution pin of the last node, Uncheck Context Sensitive and search for Set Relative Rotation. Choose the Transformation>Set Relative Rotation.
Right-click on New Rotation and select Split Struct Pin.
Drag the Value from 5 to the Z, 6 to the Y, and 7 to the X.
Drag your Directional Light from your scene into the blueprint. Then from the Blue output pin, connect that to the Target of the Set Relative Rotation. This will automatically create a node in between.
Back in Live FX, to control the X, Y, and Z, you click on the top layer, select the Canvas menu at the bottom left, and then you can use the Rotate X, Y, and Z to control the Sun in Unreal Engine (must be in play mode).
You can create a blueprint and add many components to it, then you can go to the construction script and do some custom things to have one variable effect multiple components in different ways, in this example, multiplying the intensity variable so that it would be 10x the number that goes to
Here is another example. For headlights in a city scene, we used a blueprint called "00_BP_Headlights", which is a simple actor blueprint with a single Spot Light component.
Inside of each vehicle blueprint, we brought in this blueprint twice, these two act like the headlights.
In the Level blueprint, we Get OSC Message Float At Index, then Get All Actors Of Class. We select the class 00_BP_Headlights, then add a For Each Loop, and set the intensity to the Value set in the OSC message.
Remember, the numbers that correspond in Live FX are the following from the top dummy layer: