Variable/Blueprint Issues

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

Monster Blueprint, the speedup variable controls his speed

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,

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

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.

This is it

Thx for the help! Super appreciated!