# Getting variable from different instance of actor

**URL:** <https://forums.unrealengine.com/t/getting-variable-from-different-instance-of-actor/596668>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE5-0, Blueprint, question\
**Created:** [July 4, 2022, 9:24am UTC](https://forums.unrealengine.com/t/getting-variable-from-different-instance-of-actor/596668 "2022-07-04T09:24:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SPIDERRYBESGAMIN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SPIDERRYBESGAMIN](https://forums.unrealengine.com/u/SPIDERRYBESGAMIN)\
**Post date:** [July 4, 2022, 9:24am UTC](https://forums.unrealengine.com/t/getting-variable-from-different-instance-of-actor/596668/1 "2022-07-04T09:24:20Z")

</div>

Hey guys,

So im messing around with the first person shooter template. Created actors that are enemies and gave them a health pool. I wanted to create floating damage numbers which I did in probably an incredibly jank way.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/5/24581d7953b37dd520c773d146d6519391add853.png)  
All in the enemy’s BP. When an enemy takes damage they save the damage taken as a variable (damage amount). then spawn an actor which displays that damage value.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/4/4/7442f5785c6a369c16677cb98e6ca2cf682c32d1.png)  
All in my Floating Text BP. This works perfectly when there is only one instance of my enemy but any more than 1 and all of them besides the first to spawn just display the last damage the “original” took not the amount they should have took.

Does this have something to do with using get actor of class instead of all actors of class? Any help would be appreciated. I am brand new to Unreal and Blueprints.

TLDR: one instance of my enemy shows correct numbers. rest show default if shot first, last damage of “first” enemy if shot 2nd

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 4, 2022, 9:48am UTC](https://forums.unrealengine.com/t/getting-variable-from-different-instance-of-actor/596668/2 "2022-07-04T09:48:57Z")

</div>

No need to spawn additional actors (expensive!) or `GetActorOfClass` (that’s currently the problem).

- each enemy has a widget component
- when they get hit, their own widget shows their own damage:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/c/a/eca3ef3c0e65a1f2f446430898548321a95c5479.png)

The above goes into the Enemy blueprint.

* * *

And once you’re ready for something more funky:

> [@Damage displayed](https://forums.unrealengine.com/t/damage-displayed/99716/3):
>
> Or use a widget: The widget is quite plain. You can add colours, crit sfx, alter font size, add outlines and so on. [widget.png] On Construct you position it in the viewport via an exposed variable and you set a target location for it to move towards to. The fading animating starts playing immediately. Event Tick will update its position. The animation changes text’s opacity from 1 to 0 over 1s and once it’s over, the widget gets removed from the viewport and garbage coll…

---

<div class="post-metadata">

**Author:** ![SPIDERRYBESGAMIN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SPIDERRYBESGAMIN](https://forums.unrealengine.com/u/SPIDERRYBESGAMIN)\
**Post date:** [July 5, 2022, 4:58am UTC](https://forums.unrealengine.com/t/getting-variable-from-different-instance-of-actor/596668/3 "2022-07-05T04:58:56Z")

</div>

In your “funky” example:

Are the variables Screen Loc, Dmg Val. set up in the widget? How do I go about setting up a variable in a widget? If its even possible?

Cheers for the help mate.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 5, 2022, 7:32am UTC](https://forums.unrealengine.com/t/getting-variable-from-different-instance-of-actor/596668/4 "2022-07-05T07:32:59Z")

</div>

> [@SPIDERRYBESGAMIN](#):
>
> Are the variables Screen Loc, Dmg Val. set up in the widget?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/b/44b1a56b0c87542218d3421cb3bfead9992966b7.png)

You probably mean this.

> How do I go about setting up a variable in a widget? If its even possible?

It’s just another blueprint with a normal graph:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/3/4/234209b4801f4e1fcddc257f79581b62c09bed19.png)
