Download

How to get the position of a widget in viewport?

I suppose the question itself doesn’t require any more context but if it helps I will explain what I am trying to achieve. In my game, I have created a slot-based inventory system and it works perfectly. And now naturally I want the player to be able to hover over the slots to display information about the item it contains. I thought well this should be quite easy, just get the position of the slot and offset it a little bit and show the new widget there, but to my surprise, such a feature doesn’t seem to exist.

So I started looking for alternatives, one idea is to use the mouse, the reason I can’t do that is that it’s a local coop game so only 1 player has a mouse so the rest are using gamepads and therefore I cannot simply place the widget at the mouse’s position.

I also tried being smart and using math but it just looked off and required a lot of manual tweaking, maybe I’m just not that smart but that really didn’t seem like an option. So here I am asking on the forums for help. Anything is greatly appreciated.

Lastly some screenshots of my widget setup:


This is the main widget, when an inventory is created it is put into one of the three boxes depending on which player it is.


This is the inventory widget, here the slots are created. The empty space under the equipment is where the slots would be located.


Here is the item data widget, that I want to be shown when a slot is hovered on.


Lastly, this is what it looks like in-game. As you can tell right now the temporary solution is to just add it to the corner of the screen but that is less than ideal.