Cast to widget


what do i put in the object wildcard?

I believe the widget would first have to be a persistent variable and, in most cases, it isn’t. Casting arbitrarily to a widget is not easy in that respect… The object would most likely result in a “Accessed None” situation.

A more solid approach would be to retrieve those variables from inside the widget by casting to the blueprint in which they are stored from EventConstruct or EventPreconstruct and populate them at that point.

1 Like

ok, but i only want to run the display items event when you pickup an item. do i just call the function every tick in the widget?

You could probably use a box collision on the actor in question and do a “OnComponentBeginOverlap” and create the widget then. Or if you’re using an interface for pickups you can call the function when you execute the pickup.

I believe there are several ways you could achieve this without using any kind of tick event. If you must approach this with a tick I would suggest using a timer instead to save on the cpu as you probably wouldn’t need to check on every frame to call the function…

1 Like

ok it works now.
all i did was, in the level blueprint, i casted to thirdPersonCharacter and set a variable to the widget obj ref output node on the widget construct block.

1 Like