2D Sprite On Clicked Event Not Consistent

Hello Everyone,

I have a problem that’s really beginning to make me scratch the back of my skull.

My 2D sprites aren’t firing off the “On Clicked” event every time. I thought that maybe the sprite was too thin and it was having some problems because of that so I just added a collision box and still. It fires off every 2 or three clicks but not every click. What might be causing this?

Let me guess, it always fires on double-click, though, right?

Yeah mostly, any ideas? And also, everytime I start the game. It never fails the first time I click on it.

Yeah, sounds about right. See if this helps:

Checked my settings and had it just like you, except for the mouse lock mode but after changing it to match yours it didn’t help =(

Do you have any widgets on the screen?

Just my main HUD widget. However, I’m trying to click on a 2D sprite in the game.

What could be happening is that a widget consumes the first click and that click is considered handled, in which case this click is not sent through to the player controller for further processing. This will make double clicking seem to work fine, for example.

Consider temporarily disabling widgets (do not create or add them to the screen), this might help you isolate the problem.

I will try this and report back. Thanks for your suggestions!

I’ll just add that I replicated your setup in a clean project, a single actor with a sprite + box collision set to block all dynamic, controller event clicks on. And it does seem work well, on my end at least.

Changing default viewport mouse capture mode to Capture Permanently produced the inconsistent behaviour you initially described. Including initial mouse down in the capture mode makes the collision box register every click correctly.

After disabling the main HUD widget (The only one I have) it’s still doing it.

Can you create a new actor with a cube, drop in the same level and test its onClick->PrintString

If I’m not mistaken, we’re dealing with a derived class here, right? Is there anything special about the parent? - ignore this, I misinterpreted your image.

Is there something in the construction script you might have forgotten about?

I know you said to ignore, but I tried it anyway just to be on the safe side. I created a new cube and made it a blueprint actor. After that, I created a box collision and added the on clicked event to it with a print string. The same thing happens. I can get the first event great! But after that, it takes to clicks to fire off. The construction side I have empty.

Hm, do you change the input mode anywhere in your project using one of those:

Had this connected to Begin Play and as soon as I detached it, it started to work as expected! Thank you so much for your help!

Wicked! There should be a tickbox under the upvote/downvote.

If in doubt, see here, second image:
https://answers.unrealengine.com/static/how-to-use-answerhub.html

Good luck with the project!