Click on actor = display a widget

The most straightforward way to do it, is to override the actor’s onClicked:

If you want to specifically use the trigger for it, select it and:

217459-trigger.png

And enable click events in the controller:

217458-controller.png

2 Likes

Hi! First of all, I’m fairly new to this, so the solution might be right in front of me but I can’t see it. The thing is, I have tried everything to make this work but I can’t seem to achieve it.

I have an actor, which is a billboard image with a collision sphere around it, just like this:

And I also have a widget with a text message and a button to close it.

In my scene, I have various of these actors (number 1, 2, 3, etc.) around, and my intention is to be able to click on them and display the widget (each actor would display a different widget), no matter how far or close thay are, as soon as I can see them (not whitin an area, just anywhere).

I guess It is possible, but I just can’t make the actor clickable.

Thanks in advance!

Thank You!! It worked! What I was lacking was a a custom player controller with the click events enabled. With it activated, clicking on the collision sphere works like a charm :slight_smile:

That’s great. If it’s working as intended now, consider flagging this issue as answered

1 Like

You do not need a custom controller - what you have is fine. The onClick is using Blocked Visiblity channel. Could you share the collision setup of the actor you’re clicking on?

1 Like

Hi, why exactly do i need a custom player controller? What I did was this:

But it doesn’t work. The event in the actor does not get called.

1 Like

To clarify, here’s the very minimum that you will need for this kind of click to work:

  • something with collision
  • enabled Click Events in the Player Controller
  • at least Collision EnabledQuery Only
  • blocking Visibility Trace Response
  • no widgets in the way
2 Likes

Thanks for the response.

That does not help. It must be something wrong with the controller…

I created a new clean blank project and in that project, it works even with the default collision settings:

320595-collision.png

But in this project it does not work for any actor no matter what I set. The level has a default settings as well though, there are just a bunch of static mesh actors and instances of the actor I am trying to make clickable.

Will go over my C++ code if there isn’t anything breaking it. But the thing is that the code should not kick in this basic level…

1 Like

the default collision settings:

It will work with defaults, sure - I just wanted to highlight the very minimum that’s needed in case you wanted to trim things down.

I created a new clean blank project
and in that project, it works even
with the default collision settings:

What is the element that has the collision? Is there one? You’re showing settings of the root here which has no collision of its own. You need a component that can block visibility response; no components = no collision…

Can you show the actor hierarchy?

1 Like

You could also start testing it like so:

Or you could line trace from the camera towards the cursor.

But the basic actor onClick is reliable enough providing nothing else gets in the way and the interactive element’s screenspace size is larger than a pixel. Clicking on tiny things can get annoying.

Do note that the actor components can implement their own click events if needed:

320606-screenshot-2020-10-30-143035.jpg

2 Likes

I am sorry, yes I posted a wrong screenshot. But anyway that was not the point. I have figured out what was the problem.

In the project settings, there is a “Use Mouse for touch” option which in my case was set to true. Disabling the option did the trick.

Anyway touch support in UE (at least on Windows) is still terrible. We do have issues with it all the time.

But on this project, I don’t need touch screen support so I think I will just keep it disabled.

Thanks for all your help!

2 Likes

Thank You!

1 Like

Would it be ok to assume that for “use mouse for touch” or on touch devices we could use “GetHitResultUnderFingerForObjects” and “GetHitResultUnderFingerByChannel”?