# Making Character Stat variables communicate with each other?

**URL:** <https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515>\
**Category:** Blueprint\
**Tags:** variables, unreal-engine, Blueprint, question\
**Created:** [June 5, 2024, 8:47am UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515 "2024-06-05T08:47:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignavuss](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ignavuss/32/945780_2.png) [@ignavuss](https://forums.unrealengine.com/u/ignavuss)\
**Post date:** [June 5, 2024, 8:47am UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/1 "2024-06-05T08:47:09Z")

</div>

Hello there! I’ve created some stat variables for my character. But these stat’s boundaries or values can change when other stat’s changes too. For example: my current health cannot be higher than my max health, or when my luck gets increased my crit chance has to gets increased too etc. I can make them minimum values in details section, but don’t know what to do with the other problem. Thanks in advance!  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/a/18af2db347846787b3575fd8ab9afb8e40015e7d.png)

---

<div class="post-metadata">

**Author:** ![SpudMcKenzie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spudmckenzie/32/937130_2.png) [@SpudMcKenzie](https://forums.unrealengine.com/u/SpudMcKenzie)\
**Post date:** [June 5, 2024, 9:30am UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/2 "2024-06-05T09:30:44Z")

</div>

Hello there!

I totally understand what you’re going through. I had a similar issue in my project. For ensuring that `CurrentHealth` doesn’t exceed `MaxHealth`, you can handle this in Blueprints by creating a custom event that checks if `CurrentHealth` is greater than `MaxHealth`, and if it is, set `CurrentHealth` to `MaxHealth`.

For linking `Luck` and `CritChance`, you can create a function to update `CritChance` based on `Luck` and call this function every time `Luck` changes. This way, when `Luck` increases, you can automatically adjust `CritChance` accordingly.

This approach worked well for me, and I hope it helps you too!

---

<div class="post-metadata">

**Author:** ![ignavuss](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ignavuss/32/945780_2.png) [@ignavuss](https://forums.unrealengine.com/u/ignavuss)\
**Post date:** [June 5, 2024, 11:37am UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/3 "2024-06-05T11:37:12Z")

</div>

Thanks a lot for the answer, and also I should make an event for the luck’s change, just like the health event, right?

---

<div class="post-metadata">

**Author:** ![ignavuss](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ignavuss/32/945780_2.png) [@ignavuss](https://forums.unrealengine.com/u/ignavuss)\
**Post date:** [June 5, 2024, 12:02pm UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/4 "2024-06-05T12:02:11Z")

</div>

I’ve done something like this, and I will call this event whenever a luck changing thing happens right? Game development is HARD

 ![Ekran görüntüsü 2024-06-05 150000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/8/778a432155856693d89536f2dad4849ed4f95c6c.png)

---

<div class="post-metadata">

**Author:** ![SpudMcKenzie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spudmckenzie/32/937130_2.png) [@SpudMcKenzie](https://forums.unrealengine.com/u/SpudMcKenzie)\
**Post date:** [June 5, 2024, 2:14pm UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/5 "2024-06-05T14:14:04Z")

</div>

Yeah spot on that should work, let me know if you run into any issues when testing it out

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [June 5, 2024, 2:20pm UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/6 "2024-06-05T14:20:15Z")

</div>

a fancy way is to use objects as attributes. the objects can then bind to when their ‘parent’ attribute changes.

so Luck updates, calls an eventdispatcher, critchance is bound to that dispatcher and updates its ‘luckbonus’

this also lets each attribute have its own maxvalue and can clamp when edited.

slightly simpler is to use a struct for each attribute  
(  
value  
maxvalue  
additive bonus  
multiplication bonus  
)

---

<div class="post-metadata">

**Author:** ![ignavuss](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ignavuss/32/945780_2.png) [@ignavuss](https://forums.unrealengine.com/u/ignavuss)\
**Post date:** [June 5, 2024, 3:17pm UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/7 "2024-06-05T15:17:25Z")

</div>

I used struct before but didn’t think of it that way, seems pretty logical, I will adjust some variables like that, Thanks a lot!!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [July 5, 2024, 3:18pm UTC](https://forums.unrealengine.com/t/making-character-stat-variables-communicate-with-each-other/1890515/8 "2024-07-05T15:18:13Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
