UMG read variable of an object?

I have a object with variables I want to display on screen when mouse click. I have UMG textblock on screen, instance of the object, then I get variable form instance and convert to text. But variable isn’t showing correctly. Shows 0 but variable its 12.

If you have bind your text block in content / text and not another bind with a function : get object reference / cast to / drag the element / to text / return node your trouble is on your reference. Be sure that it is specifically the object set in your level, not a generic one. If you did something different then it may comes from that.

Let me give a scenario. Say you have a truck with a BP in world, you move mouse over it and hud pops up. The hud tells you the value of damge, gas level and so on. But the values are stored in the truck BP. So In my truck BP on mouse over, it creates widget, displays values, then removes from viewport. I have all that working, but my bind, say to the gas, is not showing the value I have for the gas. In my UMG BP I tried to reference the truck BP by adding it as a variable. Then tried adding an actor then casting to the truck BP and get the variable that way. Both ways say failed to find property. Idk bug?

I think your trouble is that your reference is not the right one. When you create your widget / set hud / add to viewport, do you drag a set “object” and set it with your hovered object ? And then use this reference to cast to and drag your variable ? Edit : you may not need to cast to but directly can drag your variable from your reference like that. i now wonder about this.

And do your cast is the right one ? It happened to me to change a character and forget to change the “cast to” and of course, it didn’t work :stuck_out_tongue:

Yeah im getting the right variable because its has the right name I named it. And I have no character, its a point a click game. Im using spectator pawn class as main pawn, with static camera set in the world. So things are in world and when click it shows stats for object.

I sadly not had much time to try to help bu i did that which is a first step to help. I created a puzzle project, set mouse over event and added an int index in block with index value from blockgrid and a bool over. Then :

Create is not clean and need a better work but this is a first step.

Um i think you didnt think correct about the Reference stuff you create a widget on mouse over everytime you move the mouse over, you also drag of the wire from the create node wich can cause strange behaviour. Also Get All ACtors of Class is evn marked as a “Slow” function.

Ive made you a demo just unzip those files to your Content Folder

Its a “Truck” Actor (Actually its just a sphere) wich creates its own widget on begin play and set itself as a variable inside the widget (so we can access stuff from the widget). Also it saves its own reference to the widget to access the widget from the actorbp

Then there is the widget. You just need to remote changte the GasLevelVariable and it gets updated in the “tooltip”.

If you have any questions just ask them. I think this is exactly what you want

(mouse was over the right ball)

I totally agree about create, i wrote that too. But i thought better to give a first step working even bad and having return on it than doing nothing and let trouble unsolved.

Hmm iam not a friend of half baked solutions… thats why :slight_smile:

You right, as he said that his bp truck part was ok i would had just point on the get all actors part and let him do the link with his own system, that would have been better. Anyway, if DJ-INSERT likes your tick, that’s great. And if he prefers only replace its reference by a get all actors, he will can too.

He would need to tick so or so to update the widget position :slight_smile: if you have alot of actors the “GetAllTHing” will consume alot of resource … however you could actually do everything into one tick and just perform those tickactions if the widget is visible

Hey thanks for the replys! I have my setup almost exactly like fen, except with out get all actors and loop break. But everything else is the same. I will take some screen shots tonight and you can see. I have 2 screens though, and every time I take a shot it puts both screens in same shot. So its hard to see. Is there a button to switch that for that on windows 8?

Ok I got it to work with ruohki’s method. Now I have more question lol. Say my truck has several different drivers with many different stats each. I want player to pick driver and have stats for that driver set in the truck blueprint, then onto the hud. I don’t need help with the hud button setup, just passing variables. So should I make a masters blueprint with all drivers in it and call functions with variables in outputs? Or a different way. Because I’ve tried to do something like that and no variables are passing from master driver to truck.

Make a master bü with all vars etc for your trucks and dour drivers also set up a driver var in the truck and a truck var in the driver. That way you can easily access the drivers values even when you just have a rev for your truck