I can't get a 'key' count to work (an integer variable printed on my HUD) and I have no idea why.

I’ve followed a couple of slightly different tutorials to make a custom binding and then print that in my HUD, I follow them to the letter, compile with no errors, but the number just won’t show up on my HUD, the image element of my HUD is fine, if the text is unbound it comes up fine and I’ve printed the integer value from the variable in the ‘key’ actor so I know that works, any help would be much appreciated.![alt text][1]

I don’t get what you have going on with the KeyReference, if you bound the text field to an int, it would look like:

289671-bind.jpg

( where is the key variable? )

I’m suspecting you reference to the key actor is not set, it might be more helpful to do:

From your other screenshot I take it the cast might go wrong or the “Key Reference” might just not be set. Maybe the “Construct” Event is too early for it to be set?

Key Reference is an actor or some object having the “Keys” variable set?

Could you elaborate and tell us what you are trying to achieve and how?

Cheers

PS: Now that I took a closer look, the BP in screenshot 2 doesn’t make sense at all to me… You’re getting the variable KeyReference, casting it, and then again setting the cast value to the same variable … ? If you post some more information, it might be easier for us to help you :wink:

what is the ‘get’ node attached to the array ‘out of actors’ output and the ‘target’ input?

You said you had a ‘key actor’, I’m assuming this is a BP that contains the count. If that’s the case then this is how to bind the text box.

If you have one key actor, the ‘get actors’ node will find it, and it returns an array, which GET gives us the first ( and only ) entry from.

When you pull a pin from the GET you’ll find ‘get keys’ ( assuming your integers is called keys ). This will give you the structure you see above…

If that’s all wrong, can you be specific about the situation? :slight_smile:

Okay I did the blueprint as you suggested and it did not work. What I am doing is as follows:
-I have a ‘key’ actor with an integer variable called ‘keys’ in it that is set by collision between my pawn and the key actor, and is 0 by default, this part works as I have printed the counter using a ‘print string’ node and it can count the number of keys.
-I tried to cast to the ‘key’ actor on ‘event construct’ in the HUD event graph in order to create a ‘key reference’ object reference variable (I realised I did that wrong and so have changed it to what I believe is the correct form?, based on your blueprint, see picture)
-I used the key reference in a new function to create a custom binding so that I can print the number of keys on the HUD

It’s still not working

What I am doing is as follows: -I have a ‘key’ actor with an integer variable called ‘keys’ in it that is set by collision between my pawn and the key actor, and is 0 by default, this part works as I have printed the counter using a ‘print string’ node and it can count the number of keys. -I tried to cast to the ‘key’ actor on ‘event construct’ in the HUD event graph in order to create a ‘key reference’ object reference variable (I realised I did that wrong and so have changed it to what I believe is the correct form?

see picture) -I used the key reference in a new function to create a custom binding so that I can print the number of keys on the HUD

It’s still not working

Hi - you need to do the code in the ‘bind’ variable section, do you know where that is? Do it just like my example above ( with the purple nodes ). The text box wont show anything until you bind it to the variable.

289757-bind.jpg

Do you have a ‘key’ blueprint, or did you actually place an actor in the world?
If you did not place it, GetAllActorsOfClass will find 0.
Try setting a break point after the cast and see if the variable is actually set at some point.
If you find something and it still only reads 0, how do you change the value? Maybe it just doesn’t get changed ever.

Yes I did that already and it didn’t work, so I then proceeded to do it as shown above, similarly non-functioning

I do have a key blueprint and it is placed in the world, the variable functions as it should, adding 1 to the counter when I pick up a key, I used a break point and on the ‘cast to key’ and the ‘set key reference’ and found that the variable is being set on ‘event construct’ as intended although I’m not sure what you meant earlier about ‘event construct’ being too early to set the reference?

I managed to fix it, I’m not sure how, rather than using a binding I used the ‘keys’ key reference, which I did try earlier to no avail, I tried again because why not? and it worked, not gonna mess with it anymore, thanks for the help

You said above you got it working. If that’s the case fine. If not, say so, and I’ll send a link to a small project.