Categories
Final Major Project

Digital Twin of the LED Light. Referencing in UE5

LED on breadboard IRL

DIGITAL TWIN OF LED in UE5




Referencing allows for communication between blueprints, the sender and the receiver.


To enable communication between two Blueprints in Unreal Engine — for example, a sender (like a serial communication Blueprint) and a receiver (such as a Spotlight Blueprint) — I followed the steps below:


  1. I saved both Blueprints in the same directory to ensure that one could easily reference the other.
  2. I placed both Blueprints in the World View by dragging the sender and receiver Blueprints into the level so they existed as instances in the world.
  3. Next, I created a reference variable in the Sender Blueprint (the one responsible for sending data).
    In the Variables panel, I clicked the + icon to create a new variable and changed its type to the class of my Receiver Blueprint (for example, BP_Spotlight).
    I named this variable ReceiverRef to keep it meaningful.
  4. After that, I made the variable editable.
    With the variable selected, I went to the Details panel and checked Instance Editable (the small eye icon appeared next to the variable name).
    This allowed me to assign a reference to the variable directly from the Level Editor.
  5. In the level, I selected the Sender Blueprint instance and, in the Details panel, found my editable variable under the Default section.
    I then used the dropdown menu to assign the Receiver Blueprint instance (for example, the Spotlight Blueprint) that I had placed in the world.
  6. Finally, inside the Sender Blueprint, I dragged the ReceiverRef variable into the Event Graph and used it to call functions, set variables, and trigger events in the Receiver Blueprint.

Resources:

Potentiometer hookup: How to Use a Potentiometer with Arduino analogRead (Lesson #7)
Serial Communciation arudino: Arduino to Unreal Engine Serial Communication


Summary:

So basically, I have creates 2 blueprints. The first one handles serial port communication. 1st the serial communication plugin that I outsourced from GitHub, but then I’ve modified it. I created a custom event that reads data coming from the Arduino as strings, converts those strings into floats, and then maps the range of values (from 0–255 on the Arduino side) to a new range of 0–100,000 in Unreal Engine. This mapped value represents the light intensity inside Unreal.

Using that data, I update the light’s intensity in real time, making the digital twin of a red LED in Unreal Engine. I managed to get the two blueprints communicating with each other by referencing the red light blueprint inside the serial communication blueprint.

Next steps:

Now, I’m going to be working on a new blueprint for the character animation. I will be working with Unreal state machine and transition state that will be initialised with Arduino data. I want to use the Arduino data again to control this transition — for example, switching from idle to walking when the input value crosses a threshold.

Let’s say if the Arduino’s light intensity value is greater than 100, I want the character to transition from idle to walking. In other words, the character’s animation changes dynamically based on the real-time Arduino input, reflecting user interaction and sensor data in the scene. This will be a real-time interaction of predefined animation states.





Leave a Reply

Your email address will not be published. Required fields are marked *