x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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? alt text

Product Version: UE 4.18
Tags:
capture.jpg (236.1 kB)
more ▼

asked Jul 04 '18 at 05:31 PM in Blueprint Scripting

avatar image

warhulk1745
31 1 3 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

alt text

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!

capture.jpg (43.8 kB)
more ▼

answered Jul 04 '18 at 08:52 PM

avatar image

warhulk1745
31 1 3 4

avatar image Everynone Jul 04 '18 at 08:55 PM

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered Jul 04 '18 at 05:59 PM

avatar image

Everynone
14.6k 76 25 61

avatar image warhulk1745 Jul 04 '18 at 06:05 PM

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

avatar image Everynone Jul 04 '18 at 06:42 PM

Yeah, sounds about right. See if this helps:

alt text

untitled.png (65.5 kB)
avatar image warhulk1745 Jul 04 '18 at 07:23 PM

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 =(

avatar image Everynone Jul 04 '18 at 07:24 PM

Do you have any widgets on the screen?

avatar image warhulk1745 Jul 04 '18 at 07:29 PM

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

avatar image Everynone Jul 04 '18 at 07:31 PM

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.

avatar image warhulk1745 Jul 04 '18 at 07:39 PM

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

avatar image Everynone Jul 04 '18 at 07:50 PM

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.

avatar image warhulk1745 Jul 04 '18 at 08:03 PM

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

avatar image Everynone Jul 04 '18 at 08:14 PM

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?

avatar image warhulk1745 Jul 04 '18 at 08:32 PM

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.

avatar image Everynone Jul 04 '18 at 08:43 PM

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

http://api.unrealengine.com/INT/BlueprintAPI/Input/SetInputModeGameAndUI/index.html

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question