Is There a Way to Execute When Interface Message Turns Off?

Hey community :slight_smile:

So I have this first person shooter game where there are certain interactable objects, and some of those objects have prompts that are attached to them (in other words, not in UI space). I’m turning the prompt visibility on/off with an interface message and I got it to work. I just feel like there is probably a simpler way.

So what I basically need to do is to tell the prompt to turn on when the trace hits it, but turn off when it doesn’t hit it. This should also work when the trace transfers from an interactable object to another.

If you have an idea that would essentially do the same but with a simpler method please let me know :slight_smile: Here is my current code for it:

(Here is what is inside my “Custom Once” macro (basically the same as a normal Do Once but with an added bool reset, and outputs for after it has been done once and when it is reset)):



What is inside the interactable object:

Thanks!

Easier/better thing would be to add a collision box, detect the end overlap and remove the ui or whatever component then.

Because if you do it time based it will disappear but still be usable.
And if you do it with the trace it can glitch on/off with just a bad idle animation causing your trace to slightly offset as you stand in front of it…

“Easier/better thing would be to add a collision box, detect the end overlap and remove the ui or whatever component then.”

I want the pickup prompt to only turn on when you are looking at the item and when you can pick it up. If you do it only with an collision overlap it will turn on all the prompt for all the items nearby and not only when you are looking at it.

“Because if you do it time based it will disappear but still be usable.”

No, actually. It works just fine as it is and this trace is only for the pickup prompt, not the pickup. And it is not “time based”, since it turns on and off depending on the result of the trace?

Doesn’t matter how you make it appear. It matters how you make it disappear.
The 2 ways don’t have to be based on the same system.

“Doesn’t matter how you make it appear. It matters how you make it disappear.”

How does it not matter how you make it appear if I stated that I want it to appear when you look at the item?

Sorry, but I did not understand at all what you meant with the collision overlap method. I was gonna put a video here of how it works currently but it won’t let me upload a 30MB video for some reason even though the limit is 100MB :frowning:

If it’s a video you should probably share from YouTube as unlisted.

Whatever way you have it toggling on currently is probably OK. (It’s a bit convoluted maybe, but it works right?)

The only real problem is when and how you turn it off.

You can entierly avoid everything you have.
The do once, the interface call. And just let/allow each individual object to turn it off based on collisions.

That way you can actually turn away from the button, but still see where to go to activate it if you haven’t left its general area.

This too is not without issues obviously.
But you can actually self correct most of them by forcing a periodic check of all components which have active overlaps.

Ideally, you might include this logic to the interface call, so that if something ever went wrong and a hint was left on, you would turn it off.

Don’t assume that only one can be on at the same time though. Even if you aren’t making a MP game, it is possible to have several hints active at once, so before you turn them off, you just verify that someone/something relevant (something resolving back to a player controller?) is overlapping.

Hope that makes more sense.

1 Like

Okay, thanks :slight_smile:

I simplified it a bit and got it to still work the same way or better:

I think I’ll stick with this until it stops working lol. Btw, are Tags okay to use like this? (I wanted to use it instead of Interfaces to check the trace hit.)

Should work fine.
Tags are good to use. You just have to make sure you instantiate them right. Which you obviously did if it works.

1 Like

The way I’ve implemented my interaction prompts is similar except, the interface message is not to “turn on” the prompt. Instead the interface message retrieves any data that relates to an item that might show a prompt.

The interface call is basically a call to “GetPromptContent” and is called evey few milliseconds from a SceneComponent attached to the player camera. When you get a valid response - show the prompt and set up a reference to the object that is actively showing a prompt. When the call returns an invalid (null) reference - Hide the prompt and invalidate any reference to the active object.

1 Like