# Variable/Blueprint Issues

**URL:** <https://forums.unrealengine.com/t/variable-blueprint-issues/377289>\
**Category:** Blueprint\
**Tags:** variables-communicat, unreal-engine, Blueprint, question\
**Created:** [November 24, 2016, 8:48am UTC](https://forums.unrealengine.com/t/variable-blueprint-issues/377289 "2016-11-24T08:48:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ironsoul27](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ironsoul27](https://forums.unrealengine.com/u/Ironsoul27)\
**Post date:** [November 24, 2016, 8:48am UTC](https://forums.unrealengine.com/t/variable-blueprint-issues/377289/1 "2016-11-24T08:48:51Z")

</div>

Hey all,

So I intend to implement a blueprint system so that when the character collects the keys strewn around the map the monster becomes faster by a set amount. So far all my attempts have failed and I’m really stuck for what to do

[http://puu.sh/ssMfb/8de1e939e2.png](http://puu.sh/ssMfb/8de1e939e2.png)

Monster Blueprint, the speedup variable controls his speed

[http://puu.sh/ssMj4/bed172ece0.png](http://puu.sh/ssMj4/bed172ece0.png)

Key Blueprint, My many failed attempts at getting the variable to change

I’m sure there is a simple method of doing this so any help is well appreciated

Do I need to use a blueprint interface? Or can I do simple casting?

Cheers,

---

<div class="post-metadata">

**Author:** ![NoobsDeSroobs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoobsDeSroobs](https://forums.unrealengine.com/u/NoobsDeSroobs)\
**Post date:** [November 24, 2016, 4:42pm UTC](https://forums.unrealengine.com/t/variable-blueprint-issues/377289/2 "2016-11-24T16:42:46Z")

</div>

You need to give each key a reference to the monster and when the key is picked up you call a function inside the monster actor that speeds him up.

You can set the reference inside the editor.

HTH

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_3221808d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3221808d](https://forums.unrealengine.com/u/anonymous_user_3221808d)\
**Post date:** [December 3, 2016, 8:11am UTC](https://forums.unrealengine.com/t/variable-blueprint-issues/377289/3 "2016-12-03T08:11:31Z")

</div>

First create a function on your monster called something like handleNewKeyCollected

When a key is collected you need the key to call that function. Your options for getting a pointer to the monster are:

1. GetAllActorsOfClass
2. Use a design-time pointer. (Requires having the keys and monster as actors sitting in the level at design time)
3. Store a reference to the monster somewhere globally when you spawn it and request it from the keys(like in the gamemode). Example: get GameMode → Cast to your gamemode → get monsterReferenceVariable

For simplicity here I would use GetAllActorsOfClass.and for the class use your monster’s. Then from that array you can loop through them and for each one call handleNewKeyCollected.

handleNewKeyCollected will take the previous speedUp and add some pre-desired amount to it. The key to remember is that after you add them you store the new value back into speedUp or it won’t continuously get faster.

Also as a note, your second screenshot has you setting the PickupItem integer but the value you are passing in comes from an add node that is connected to functionality that never gets called. This will have bad results. Either plug your execution chain into the newFunction node or skip pickup item. I’m sure this is just from messing around but it will cause issues if you are relying on it.

---

<div class="post-metadata">

**Author:** ![Ironsoul27](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ironsoul27](https://forums.unrealengine.com/u/Ironsoul27)\
**Post date:** [December 3, 2016, 12:58pm UTC](https://forums.unrealengine.com/t/variable-blueprint-issues/377289/4 "2016-12-03T12:58:33Z")

</div>

This is it

Thx for the help! Super appreciated!
