# How to reduce repetition setting variable values from multiple paths? 

**URL:** <https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [April 10, 2026, 8:06pm UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411 "2026-04-10T20:06:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Schnedicles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Schnedicles](https://forums.unrealengine.com/u/Schnedicles)\
**Post date:** [April 10, 2026, 8:06pm UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/1 "2026-04-10T20:06:51Z")

</div>

Hi, brand new to unreal development so this is very basic I’m sure. I couldn’t find an answer online or in thsi forum so sorry if the answer is here already. Basically I’ve created an attack flow in my character blueprint. i wanted to reuse the attack function for various attack types and then use variables to determine the different thigns such as reach and attach power etc.

My issue is the setters at the beggining. I’m duplicating the setters for each attack type which will obviously get worse as I add different attack types. How can I have 1 line of setters here and depending on which enumerator was used to call them (e.g. which attack type) set the values differently?

A screenshot is below. Thanks for any guidance.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/a/18ad98316cba0f05a0fd086e3694c7a44f235a56.png)

---

<div class="post-metadata">

**Author:** ![Anlag](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/anlag/32/1167165_2.png) [@Anlag](https://forums.unrealengine.com/u/Anlag)\
**Post date:** [April 10, 2026, 9:08pm UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/2 "2026-04-10T21:08:37Z")

</div>

**Hey! Doing it this way will definitely make your graph hard to manage later. Here are 3 ways to optimize this, from simple to professional:**

1. **The “Select” Node (Easiest):** You don’t need multiple execution lines. Use only **one** Set node for each variable (e.g., Attack Power). In the input pin of that Set node, plug in a **Select** node. Connect your `E_AttackType` to the Select node — it will automatically create pins for “Punch” and “Kick”. Now you can just type the values directly there.

2. **Using a Struct:** Create a **User Defined Structure** with all your parameters (Power, Distance, Height). In your Blueprint, you can use a single **Select** node to switch between two versions of this entire Structure. This keeps your graph super clean with only one “Set” node for everything.

3. **Data Tables (The Pro Way):** If you plan to add 10+ attack types, use a **Data Table** / create a _ **Struct** _ first, then create a Data Table based _ **on it** _. You can fill in all the numbers there like in Excel. In your Blueprint, just use the **“Get Data Table Row”** node and pass your Enum as the Row Name. This way, you don’t have any hardcoded numbers in your logic at all!

**Method #1 is a quick fix, but #3 is what people use in real production. Good luck!**

---

<div class="post-metadata">

**Author:** ![danamaloma](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/danamaloma/32/1167197_2.png) [@danamaloma](https://forums.unrealengine.com/u/danamaloma)\
**Post date:** [April 11, 2026, 3:43am UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/3 "2026-04-11T03:43:35Z")

</div>

In Unreal Engine (Blueprints), repetition when setting variables from multiple execution paths is a very common issue. The best way to reduce this is to **centralize your variable assignments into a single execution path** instead of setting them multiple times.

#### ✅ Recommended approaches:

**1. Use a single “Set Variables” point (merge execution paths)**

- Instead of setting variables inside each branch, route all execution paths into one final node.

- Set all variables in one place.

- This keeps logic cleaner and avoids duplication.

**2. Create a Function or Macro**

- Put all variable-setting logic into a **Function** or **Macro**.

- Call it from different paths.

- This is the best solution if the same logic is reused often.

**3. Use a Struct (advanced but clean)**

- Combine related variables into a Struct.

- Pass the struct around and set it once.

- Helps especially when you have many variables.

**4. Use “Select” nodes before setting**

- Instead of branching multiple times, decide values using **Select nodes**.

- Then feed results into a single Set node.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/6/ea631f0e2e19356f73d3bf6a51c3bc71cdbdf08c.jpeg)

---

<div class="post-metadata">

**Author:** ![Schnedicles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Schnedicles](https://forums.unrealengine.com/u/Schnedicles)\
**Post date:** [April 11, 2026, 8:54am UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/4 "2026-04-11T08:54:34Z")

</div>

Thank you so much. I’ll give this a go tonight!

---

<div class="post-metadata">

**Author:** ![Schnedicles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Schnedicles](https://forums.unrealengine.com/u/Schnedicles)\
**Post date:** [April 11, 2026, 8:55am UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/5 "2026-04-11T08:55:35Z")

</div>

Thank you so much. I’ll be trying to sort this tonight so I’ll try these options.

---

<div class="post-metadata">

**Author:** ![Anlag](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/anlag/32/1167165_2.png) [@Anlag](https://forums.unrealengine.com/u/Anlag)\
**Post date:** [April 11, 2026, 9:05am UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/6 "2026-04-11T09:05:51Z")

</div>

Hope it helps you out - good luck with building the mechanic!

---

<div class="post-metadata">

**Author:** ![SpectreKelevra](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spectrekelevra/32/723050_2.png) [@SpectreKelevra](https://forums.unrealengine.com/u/SpectreKelevra)\
**Post date:** [April 11, 2026, 6:54pm UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/7 "2026-04-11T18:54:32Z")

</div>

Hey @Schnedicles , I’m glad you found this helpful and while the marked solution is correct, just be aware that both interactions are AI, you can tell by the second one’s nonsense picture and formatting, and the language and formatting of the first (marked) one.

Also, there are many many ways to optimize a setup like yours, your method will perform well, your main concern will be editing it later, the main idea is keeping it all in once place, keep it readable (for you and your teammates) and avoiding extra boilerplate and overhead like creating struct assets and data table assets which require structs and having your project balloon in files for a function that sets a handful of floats.

My general advice is, you can keep it as is if you’re only using it as is, and if it’s not bothering anyone, and optimize as you go, don’t worry about min-maxing every line of code, keep it simple, keep it readable.

---

<div class="post-metadata">

**Author:** ![Anlag](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/anlag/32/1167165_2.png) [@Anlag](https://forums.unrealengine.com/u/Anlag)\
**Post date:** [April 12, 2026, 6:39am UTC](https://forums.unrealengine.com/t/how-to-reduce-repetition-setting-variable-values-from-multiple-paths/2714411/8 "2026-04-12T06:39:49Z")

</div>

haha you got me on the formatting! English isn’t my main language, so I use tools to make my posts actually readable and not a mess. But the tech advice is mine.

I still think Data Tables are worth the effort though. If you’re planning to add a lot of attacks, it’s much better to have a system ready than to mess with code every time you want to change a few floats. Scalability is key for me, I hate cleaning up spaghetti code later.

Anyway, thanks for the input, good to see different opinions!
