Having trouble getting my text to string properly

I have been trying to make a hintstring system that updates whenever the player overlaps with something, currently I have that working just fine, the problem is I have objects that have “activated” booleans that are supposed to tell the player if something has been activated yet and if I have multiple of the same blueprint actors in a level one of them is randomly selected to be the “parent” for lack of better words and that dictates what the hintstring will say for all of the blueprint actors of that class in the level.

So for example, if the hintstring is supposed to say “Press E to fill lantern” like what I will be showing in the code and the player activates it the hintstring should update to “There’s no oil left”, now that works “kinda”. IF the hintstring does update that means the “activated” boolean was set to true and the hintstring variable I have set on the actor class has been updated, problem is if I walk to any actor of the same class and overlap with one that has “activated” as false the hintstring will still show up as the true version of the boolean.

I have tested to see if the boolean is being set to true across all duplicate actors in a level and they aren’t, the gif will show in the top left of the screen that they still false if I haven’t activated them yet, I have tried to reference the actors themselves as variables in the widget BP and the character BP but no matter what I do it will always come out with an “accessed none” error, so the only way I can get it to work is if I bind the hintstring text in the widget to get actor of class.



And here is the gif: Screen capture - 15cb5df55526277369c7d0c163330122 - Gyazo

Any ideas? I’m also curious as to why if I try to reference anything, whether that be an actor or widget, as a variable and pull the referenced objects variables from it’s node I will always get an “accessed none” error, but if I link it into a “cast to” node the error is gone but it doesn’t work like that anyways. I feel like if I could reference the actor itself rather than get actor of class that might work better than what I currently have but until I can figure out why I get that error I can’t really test it.

“Get actor of class” always returns the first found actor of that class, so you’re not necessarily getting the actor that you want if there are multiple actors of that class in the world.

What you instead ought to do is have those classes message the widget through a Blueprint Interface, telling the widget whether or not they’re being overlapped, and if so, what the hint text should be.

Trying to bind the hint text in the widget to values found in the first actor of that class in the world isn’t going to give you the behavior that you want.

It may be better to run a line trace and message any hit actors with a Blueprint Interface, get the desired hinttext through that Interface message, and then talk directly to your widget from there, passing the hinttext into a function on your widget.

The explanation for how to build systems like this is a bit nebulous but I do need to cover it on my personal blog anyway. IF you’d like to discuss it more in depth, you can get me on Discord:
JesseLeeHumphry#9842

Edit: I did actually end up writing up a post on my website that goes through a simple implementation that you can build off of. You can see it here:

1 Like

Ah I just read this yeah I’ll give this a go I also got it working by setting a hintstring variable in the character BP through another boolean and calling the character BP in the widget rather than trying to call from the actor BP’s themselves

The way I got it to work is messy though and will lead to lots of extra branches for every item that would have a hintstring associated with it.

Yeah, go ahead and read the link I posted there on my post, it walks through what I do to handle a theoretical infinite number of classes / hints without having to change the nodes. You only have to change a variable in a class and you have new hint-text.