Using a Line Trace to interact with a world space widget

Hello,
I am trying to make it possible to interact with a widget without needing to show the mouse cursor. Currently I have a line trace checking what object the player is looking at and if it is the right object it outlines the object. Then once the object is outlined the player can press ‘F’ to spawn a widget. I have got this working.
However, I now need to make it possible to interact with the widget that spawns without needing to spawn the mouse. I have a small crosshair in the centre that can act as a mouse but currently I can’t interact with the widget.
I don’t know if ‘world space widget’ is a regularly used term so to clarify I have put a widget blueprint into and actor blueprint and am spawning the actor blueprint.
This is what I have so far -

Low res pic, hard to read so I’ll ask:

Are you using a Widget Interaction Component for this? As this would be the way to handle it. It does pretty much all you’ve described, including tracing and key emulation - so you’d press F and have the widget treat it as a mouse button, evoking button presses and so on…

World Space Widget Component. So you’re pretty close.

Hey,
Thanks for the reply. Yes I have a widget interaction in my first person character. Are you meaning I need one in my widgetBP/World space widget BP?
So I need to cast to the widget interaction in my widget BP and enable input?
Thanks

No, it works as is. What is the actually issue you’re having then? Because the component does it all.

This is the job for the WIC. How are you using it?


The actual cursor would be purely visual and just slapped on top of the trace of the WIC.

The issue is that the widget spawns but I can’t interact with it at all. I initially thought it was something to do with focusing but now I think perhaps I’m misunderstanding the widget interaction component?
I thought you would still have to tell it what interaction to look for (as in telling it to capture mouse wheel or mouse clicks)

Not really. It really is that straightforward:

Note that it’s attached to the camera and Interaction Source → Center Screen. And this:

is us pretending that F key is the Left Mouse button which results in mashing F and buttons responding:

You can then place a non-interactive widget in the screen centre - this part is purely cosmetic.

Okay that all makes sense and that is firing for me. Perhaps the issue is the way I’m dealing with the world space widget?
What I’ve done is created a widget blueprint. And put that widget blueprint in an actor blueprint and am spawning that actor blueprint.
The way you said ‘world space widget component’ makes me think there is an actual component I’m supposed to use?
Thanks for this, very helpful so far.

How did you do it? Like this, right:

That’s the widget component. Its job is to manage a widget, its lifecycle, whether and how it can be interacted with, and whether it lives in screen or world space.

Yes like that, and I just checked and it is in world under ‘space’.
So the interaction to the widget isn’t based on the actor BP it’s completely based on the widget BP?

Yes. The widget component has a piece of mesh - a simple quad plane. It takes the 2d widget and paints in on a Render Target (turns it into a texture, sort of), it then displays that widget texture on its mesh.

The interaction comes from the Widget Interaction Component which performs a trace, hits the plane, does a lot of math, and sends the data to the 2d widget the widget component instantiated.

Okay, that makes sense.
I have just tried this on another widget and again, no luck. I thought maybe it was because the widget I was using has a lot of code in the widget itself, done previously by another team member. But still nothing on a new fresh widget. Is there anything I have to do in the actual widgets blueprint?

I thought it meant you got it to work :face_holding_back_tears: But no, this is all on default settings. Perhaps consider looking into what is not default.

What does it mean, specifically? What kind of interaction are talking about? Perhaps the issues is with the expectations / testing method or with the widget’s visibility? To be interacted with, a widget (and its parent) must be visible. The widget needs collision enabled, too. But that’s set by default correctly.


  • create a new widget with just a button
  • add a widget component to a new actor
  • place it in the world
  • can you interact with it?

Oh my apologies. By firing I meant the clicks are being detected but not by the widget, apologies.

I will try creating another widget, I did try this already, but worth another shot. It seems that everything is working (Widget interaction clicks are firing) but the widget just isn’t interactable? I am definitely missing something with the logic of this and I assume it’s a super simple thing which is why there isn’t many other questions on this haha

I created a fresh widget, it is detecting the mouse and going to a hover state! but not detecting any clicks.

How do you know this, how is this tested? How are you sending the click?


Will this not work for testing? Fastest thing I could think of the test it. And also the pressed state isn’t being triggered but hovered is

That’d would work unless you’ve added 10 buttons on top of each other which I’ve seen people do. Print String usually does the trick.


How are you sending the click? How is this part set up?

No print string from it either.

Release instead. Also, which BP is this in?

Changed it to release and the pressed state triggered! This is in First person bp

1 Like