Direct communication between Blueprints: references and Instance Editable
Direct communication is the most common method and works one to one: a Working Blueprint gets a reference to a Target Blueprint, usually through a variable of the target's type, and then reads its components and variables or calls its functions. The variable must be Instance Editable so you pick which instance of the target in the level it points to.
From the course
Taken from the hands-on project of the course; the lessons show every step on video.
What is direct communication?
A one-to-one link: the Working Blueprint requests access to the Target Blueprint. The simplest way is to get a reference to the target and use its publicly exposed components and variables, exchange information and call the target's functions.
The lamp example
- Place a lamp static mesh from the starter content on a wall and turn it into a Blueprint (Add Script / Blueprint) in the Blueprints folder.
- Add a Point Light component, which simulates a traditional lamp, and position it in the lamp. Adjust Intensity, Source Radius and the Attenuation Radius, the circle that shows how far the light reaches.
- The character does not know the lamp exists yet. In the Level Blueprint the lamp is already referenced because it is embedded in the level, but the character has no relationship with it.
How do I create the reference?
- In the character Blueprint create a variable, for example BP Light, whose type is the lamp Blueprint. It is a reference to that Blueprint.
- Get the variable, then call Get Point Light from it and Set Intensity, for example to 0, so the lamp looks switched off.
- Use a key event, with Enable Input called from Event Begin Play and a Get Player Controller. If the key does nothing, another event may already use it.
Why does the log say it could not access the light?
With direct communication you must say which instance of the target you want, because the scene can hold many instances of the same Blueprint. Make the variable public (Instance Editable), compile, and select the character in the level: the Details panel now has a field to pick the lamp instance. Pick instance 1 and pressing the key turns the light off.
Free PDFs that go with this page
One-page guides made from the lessons, sent by e-mail.
- Cast, Interface or Event Dispatcher? — A one-page guide to choosing how two Blueprints talk to each other, with the example from the course for each method.
- Blueprint Cheat Sheet — A free one-page PDF for Unreal Engine 4/5, made from the lessons of the course. Keep it next to your editor while you learn.
- Free PDFs
Frequently asked questions
What does direct communication need?
A reference to the exact instance of the target Blueprint.
Why is my reference empty and errors appear in the log?
Because no instance was selected. Make the variable Instance Editable and pick the instance in the Details panel.
Can I use it with many lamps?
Each variable points to one instance. For several instances at once, Cast To is more convenient.