How to make floating widgets?

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.

It’s pretty straightforward. Is every cube a separate actor?

The most straightforward way to do this:

Here, I create some objects and a single widget:

Clicking an object produces its world coordinates, these are converted into screen coordinates. Position the widget there and make it visible.

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.

I still have nothing to connect to this

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

And it will be a phone game, so is it possible to do the same with finger?

also , I don’t get what is the “card widget” in your blueprint and the comp click, I only have the widget blueprint that should pop up

I don’t understand these :

214388-card.jpg

214389-spawnactor.jpg

also, both your blueprints in level blueprint?

and I get this in mine :

214389-spawnactor.jpg

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?

Yup:

214393-mobile.png

And how can I refer to the squares?

I don’t need then 1 from the sequence?

It not gets my objects locations, it only gets my cursors.

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 HitActorGetObjectName 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?

Yea but I want to select the object and that opens the widget

That’s exactly what the code above is doing:

Yea but on my level the widget pops up everywhere on the map not only where thd objcets are(the ground is a big cube also)

That’s expected - the reason is that we check on the 2 most common collision channels. The array you connected to ObjectTypes indicates which ones.

  • you can either create a new object channel in your project settings and test for those only
  • you can filter the results of Hit by object class
  • you can use objects tags

Pick you poison, I’ll try to help where I can.

Also, most importantly, is every square a separate actor or you just dropped StaticMeshes in you level?

In addition, when you do break the hit, you can use object or component location instead of hit location:

214414-capture.png

I put a cube ont he map and duplicated it many times, the ones that supposed to open widget have tags

Tags could work, try it like so:

I made this, now nothing happens.