How to send interface calls once on begin and once on end mouse over, checking on tick?

I’m checking on tick, if the actor under the mouse cursor, being hit by the “interactable” trace channel, has the interaction interface. if so, the first time the mouse over trace hits it, it should send only once a “begin hover” interface event to this actor, and when the mouse over trace no longer hits it, it should send an “end hover” interface event, only once again.

I have this:

and it kinda works, has worked for a while, but I just noticed when I’m holding the right mouse button, it keeps firing the “end hover” event on tick. when i release the button it stops, and I have no idea why this happens, and it’s breaking one of the functions the actor should be doing on end hover, since it’s being called all the time.

I tried to do this some other way, must be a simpler method, but couldn’t find out one.

Any ideas?

Macros that have local variables don’t work inside functions. So DoOnce nodes don’t work inside functions.

Having said that, it should be impossible for the End Hover node to ever trigger. No mouse click or tick or anything can ever make it trigger inside the function you posted. It’s being called elsewhere unless they changed how local variables work inside functions.

1 Like

It’s just collapsed nodes in the event graph, not a macro, so those aren’t local variables, and the DoOnce nodes work just fine.

But you are absolutely correct, it was being called elsewhere.

However, I still think this seems a bit bloated. Can you think of a better way to do the same?

Dunno. Maybe something like this. Not sure if it’s better. It will work inside a function as long as you don’t use local variables.

If you copy from blueprintue, change the channel trace.

I thought I saw something in your graph that had an issue, but I was wrong. I’m not seeing anything wrong with it.

edit2: Updated the screenshot and blueprintue link

1 Like

At the start of your graph, if the Hovering Object and the Hit Actor are the same, the True pin of the branch shouldn’t connect to anything. Still shouldn’t matter because of the DoOnce node, but it’s better to remove that connection.

1 Like