Hi, I want to make a floating widget or something above my objects, if I press them, so my game is a tower wars and the map is built from cubes(static mesh actors),when I click one of them, i want a widget to pop up above THAT cube, with a selection of turrets or something like that.
Here is a part of the map, the orange cubes are the map(there are 288 of them) so if I click on one of them a widget appears above it, I don’t want to copy the blueprints 288x for each object, if possible with one blueprint.
Currently the widget will appear with its upper left corner centred on the click location. You can add an offset to the convert node to shift the widget around.
Okay i made it work, but the problem is (my event activator is the key “U”) so when i activate the event it prints the string(my widget) at my mouse location, it should work when i click on the object
Card is the name of my widget, so just put your widget there. I needed something to click on so I spawned some objects (CompClick) at random locations to test it out. If you already have something to click on (your squares), you obviously do not need to spawn anything extra.
I did both in the PlayerController for convenience. Can be done anywhere really.
And it will be a phone game, so is it
possible to do the same with finger?
It not gets my objects locations, it
only gets my cursors.
Well, you click on the object, the widget appears where you clicked, that’s where the cursor is, right?. Your objects need to have collision set up for this to work, naturally. Print HitActor → GetObjectName to see what you are hitting.
Or perhaps you missed the paragraph under the second image I posted, about adding the offset. If you want the widget to appear dead centre, you’d have to subtract half its size before you push the coordinates back to the viewport.
This is a very simplified version with several drawbacks. When you pan your screen, for example, the widget will stay in place, it will not track the object you initially clicked on. This is easy to sort out, though.
Are your squares separate objects or just StaticMeshes you dropped in the map?
There are several methods of doing what you want, this one gives you a direct access to the actor you clicked on, too. (Hit Actor)
Alternatively, you could cover the screen with a Widget Canvas, detect where you click, deproject to world or trace. But that’s somewhat unnecessary more convoluted.
Did you manage to get the widget to show up at all?