Get and Set in Blueprints: reading and writing a variable
A Get node reads the current value of a variable, and a Set node writes a new one. Ctrl-drag a variable into the graph for a Get and Alt-drag for a Set. Set has execution pins, so it joins the flow, and the order matters: a Print String before the Set shows the old value, after it shows the new one.
From the course
Taken from the hands-on project of the course; the lessons show every step on video.
What are Get and Set?
When you drag a variable such as a StringVar into the Event Graph you choose Get or Set. Ctrl and Alt make it faster: Ctrl for Get, Alt for Set. A Get reads the current value, which you can connect to a Print String to display it.
How is Set different from Get?
A Set records a new value during gameplay. Unlike the Get node, it has two data output pins and two execution pins, so it connects to your execution flow, for example after Event Begin Play.
Example from the lesson
- Connect Event Begin Play to a Set of StringVar and define the new value, NEW TEXT.
- Connect a Print String at the end and connect the Set's data output to it.
- When the scene starts, the Set redefines the value and then the Print String shows it. The original default value is not shown.
Why does the order matter?
The Print String shows NEW TEXT because the value was changed before printing. If the Print String came before the Set, the printed value would be the default value of the variable.
Free PDFs that go with this page
One-page guides made from the lessons, sent by e-mail.
- 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.
- Variables and data types — What each Blueprint variable stores, plus the Get, Set and struct moves that go with them.
- Free PDFs
Frequently asked questions
How do I create a Get or Set quickly?
Hold Ctrl while dragging the variable for a Get, or Alt for a Set.
Does a Set node have execution pins?
Yes. It connects to the execution flow, unlike a Get.
What does Set do to the default value?
It changes the value during gameplay. The default value in the Details panel stays as it was defined.