I am developing a tower defense game, and created a plate(called tower-pods) with a widget for building towers.
However, the widgets often fail to recognize clicks, so it becomes very hard for game players to click buttons.
Please see the GIF link below. I placed 6 tower pods. Red circles are clicks.
As you can see, I could create a right-most tower easily, but I had really hard time to create tower at other positions. It seems that the widget button recognize the mouse cursor (since it becomes brighter), but for some reason it doesn’t take my click. How should I improve this?
The widget is like below
When the ‘1’ button of widget is clicked…
This is the tower pods(base for tower). It has a cylinder on top, and if the cylinder is clicked a widget will show up.
And when the cylinder button is clicked. A widget is spawned. as in the link below.
I’ll admit it does look a wee bit odd. I’m going to make a couple of assumptions here, could you confirm these:
Receive Hardware Input is enabled (this must be true, surely)
- nothing is overriding onMouseDown / Up in the widget?
It might be a weird focusing issue as the widget appears under the cursor; could you try setting user focus manually:
See if that helps at all.
Also, could you show the hierarchy of the widget?
And since this is a widget component, can we see the actor hierarchy? Is there a sphere collision somewhere that can be consuming input prematurely, or another component that could interfere? Made not Visible so it does not show up in the viewport?
Are you using LMB anywhere else in the project?
Yes, ‘receive hardware input’ has been checked, and nothing is overriding on-click event.
I added Set User Focus as the picture in the link below. Clicking widget’s button became a bit easier, but didn’t fix the issue fundamentally. (Also the widget’s hierarchy is included in the link)
I didn’t know this can be related to focusing, so thank you very much for your reply. I will check overall focusing/controller logic.
The hierarchy looks more than fine. Thank you. Lets keep digging:
- perhaps the buttons are set to Precise Click?
- could you confirm the Text Blocks are set to Not-Hit Testable (Self Only)
Thank you so much for your interest!
No buttons are at the ‘down and up’ mode.
Text blocks in the widget had been at ‘visible’ mode. So I changed it to ‘Not Hit Testable(Self-Only)’ as you mentioned. However, the issue is still happening.
The TowerPods actor is like below. I enlarged the ‘tile’ to check easily whether interference exists.
Also I drew a few purple lines to show what they are in Component hierarchy.
- Button : the cylinder on top. This takes ‘click’ event to add widget and to show/hide the widget
- Scene : used to hold location information for the widget. It is a very small sphere right below the button. (This is being selected in the picture below)
- Tile : the cube at the bottom.
These are configured as below.
As you can see, there is no extra collision.
- Currently nothing is using LMB. LMB action mapping is not registered in project setting.
I removed all other actors except for this TowerPod, but nothing changed.
Currently, level BP is the only BP I have other than this TowerPod and its widget.
To check if the ‘enable mouse over events’ affects something, I removed the node, but nothing changed either.
- To check if there is something to cover widgets, I played game in wireframe mode.
Here I found the widget takes relatively huge space, and doesn’t disappear after I created tower.
I will figure out how to fix this, but I don’t think this is the fundamental cause, because this symptom happens even when I click the first tower for the first time after I run the game.
I’ve replicated the widget, simplified it to this:
- each button lives in a grid slot
This seems to work pretty well.
Consider adding widget component to each tower (rather than spawn it dynamically) so the tower already comes with its own widget - this will also simplify communications between the 2. That widget component can be hidden when not in use.
Fantastic! I have been suffering from this for hours and days, and you saved me HUGE amount of time. I will also switch the dynamic widget to static one as you advised. Thank you so much and have a great day!