Action OnClick not working (UE4-27)

Hello !

I’m brand new to UE and in general on game developping.

I started yesterday with a guide where i learned all kind of things and wanted to start making a prototype. ( by the way, sorry for my english, i’m french )

The problem i have right now, is that i want to make so my character can interect with OnClick events with Left click, so i added Interaction on the Action mapping, using the Left Mous Button (

)

but then, nothing happen even if i set my Onlick action like that on the blueprint i created for the DoorBell i wanted to make :

I also wanted to make so when i’m overing the door bell, the cursor switch to a hand but it doesn’t show anything.

To be clear, i followed a tutorial on getting a clean setup for developping, so i created my project with Third Person one from EG, and transformed it to a FPS by moving the camera, adding head movement etc ! So, my question is, can i actually stick a cursor in the middle of the screen, hidden but active, that i can replace it with just a black dot, and make it switch to another cursor when overing things, and be able to onclick event with that.

Sorry again, not really used to speak developping + in english. Don’t hesitate to tell me if i’m not clear enough

You could but it would be awkward, hacky and not really necessary.


There are many methods to invoke a cursor → actor interaction. If you wish to you use the method you already have, it’s a matter of enabling the player controller to process those clicks:

image

Similarity, there is also interaction from the mouse over:

image

If you have yet to make your own controller, you can do this in the player blueprint instead:

Do note that the thing you’re attempting to click on must block Visiblity traces. If I wanted this cube to receive a click, I’d need to ensure that we at least block that one thing:

image

This is generally fine by default, though.


Now, most importantly, do we really want to use the mouse cursor? I am under the impression you simply want to look at something and then press LMB to interact. In this case, we wouldn’t be using the mouse cursor at all.

But perhaps you want to wiggle the mouse cursor around and click, who knows. Could you confirm?

cursor in the middle of the screen, hidden but active, that i can replace it with just a black dot, and make it switch to another cursor when overing things, and be able to onclick event with that.

Judging by this you want to have an indicator in the middle of the screen altering its looks based on what actor the centre of the screen is pointing at.

How close am I?

Thanks for the fast answer ! one of the problem i have with the “Show Mouse cursor” is that it lock the rotation of my camera while playing at a approx. 180° angle and not 360° ! and it actually doesn’t show the cursor, or actually not on my line of sight since it was a third person pattern that i swapped to FPS just by moving the camera on the mesh

Now, most importantly, do we really want to use the mouse cursor? I am under the impression you simply want to look at something and then press LMB to interact. In this case, we wouldn’t be using the mouse cursor at all. But perhaps you want to wiggle the mouse cursor around and click, who knows. Could you confirm?

Yeah, that’s the point where i’m not sure about, i want to do an horror ambiance based game, and in my head it was no UI at all, not even a pointer, but feels like people would loss where to aim to actually interact but i guess it’s the best way to make it immersive !

For now i created an UI that display a simple Black dot in the middle of the UI, but will probably remove it then

That’s the way to go, you could always consider showing a small blip icon for a short period only when looking at a point / entity of interest.

  • next, you’d want to use tracing (instead of onClick) along the forward vector of the camera, this will return the reference of hit actor / components.
  • not sure what other interaction are needed but judging by your description, the player will interact with a plethora of random items / elements - I’d immediately start looking how interfaces work as this is the most natural system for this kind of interaction.

Exactly what i was thinking first ! but totally don’t know how to do that tho

Okay, u totally lost me on this :x my bad english + beginner doesn’t help sorry

not sure what other interaction are needed but judging by your description, the player will interact with a plethora of random items / elements - I’d immediately start looking how interfaces work as this is the most natural system for this kind of interaction.

it will mostly be light switches, door opening etc… not yet figured out how doors works but shouldn’t be that hard

Aye, interface is what you need:

  • tracing:

In short, when we LMB, a line is shot into the world following the direction of where the camera is currently looking. If we hit something, we’ll know what it was.

Now that you know that you’ve hit something (door, bell, monster, wall, collision volume) you can send that entity a message.

Do look up Interfaces on YT. They will allow you to send a generic message to the hit actor and that actor can interpret that message any way you need.

If you hit a bell, it will ring. If you hit a door it will open…


A quick and dirty example:

1 Like

Thanks ! feels easier to understand with visual support !

So, the Get Forward vector get the vector of where the camera is pointing, + the getactorlocation gives where the character is then it’s all you said !

Is there an easy way to actually limit the range ? so like i need to be pretty close to the bell to actually have the UI showing up that i can press it to ring ?

  • can i actually do that in the PlayerController or i have to do it in the Character blueprint ?

Yes, I multiply the vector by 10000 unreal units - that’s 100 meters. You may want to lower it.

can i actually do that in the PlayerController or i have to do it in the Character blueprint ?

This should, ideally, be in the PlayerController. Folks usually have a Pawn running around before they have a controller so I just quickly dropped in the Pawn to avoid confusion.

Thanks a lot ! i’ll give it a look by myself and try to figure it out !

Sorry again if there was dumb questions ^^

1 Like