How to show widget when get inside of Collision box AND mouse pressed on the Staticmesh? (Multiplayer ony)

How to show widget when get inside of Collision box AND mouse OR “touch” pressed on the Staticmesh ?

i mean need to show Widget when mouse OR touch pressed on the Static mesh

Collision with Overlap event and Mouse / Touch with LineTrace (Get Hit Result Under Cursor and the respective part for Touch) could work?

@Pantoth can you show me on the blueprint?

These nodes should give you the option to check your mouse / touch position.

And for your Box collision you have events that check if something is overlapping / inside.

image

I don’t have time to spare to set it up myself right now, but I believe there are some tutorials out there that cover these nodes. Maybe I’ve time tonight :slight_smile:

1 Like

@Pantoth thank you. now i’m testing this nodes. if you have time please setup it for everyone. i think this forum will help other people :grinning:

some thing like this right?

Disclaimer: I’m no Pro! That setup may not the best example, but it works. :nerd_face:

Ok! A quick example for Mouse only. (Should be somewhat similar with Touch)
This is my setup: Box Collision and a Static Mesh that ‘checks’ for an overlapping mouse cursor)

First Blueprint is BP_Object2Click (the one above):
Two events to detect if something is On Begin Overlap / On End Overlap and a cast to my FirstPersonCharacter to toggle a Boolean on or off, depending on which event was called.
(additional Event Tick with Print String to get some immediate feedback)

Next is my FirstPersonCharacter Blueprint:
A Left Mouse Button event checks if the Boolean is True. (the same Boolean that will be changed with the Overlapping Events) If true, there will be a Get Hit Result Under Cursor. (either Objects or Channel, depends on your preferred setup) If that Trace was successful, you can use a Cast node to check if the Actor that was hit is, in fact, your required Blueprint (in my case: BP_Object2Click). From there on you can create Widgets and so on …

For Touch it may be similar: Get your OnTouch event, check for Boolean and then Get Hit Result Under Finger (Object / Channel).

: EDIT :

Totally forgot the details: I used Get Hit Result Under Cursor By Object.
There you’ve to create an Array of Object types you want to trace. You can drag + drop the Object Types input and create a new Variable.

image

Then, in my case, I used the Object Type ‘WorldStatic’.

: EDIT #2 :

Make sure that the object you want to click on has the same Object Type (under Collision) as in the Object Types array you’re tracing for!

And if the Cast still fails you may want to add a Print String node to get some insights about what information your Get Hit Result node gives you.

2 Likes

@Pantoth is working on multiplayer?
So directly calling third person character is not affect other players right?

I don’t have any experience with Multiplayer in Unreal Engine. Can’t help you there : )

1 Like

i tested it and cast BP_Object2Click is failed

what should i do?

What does your Blueprint look like?
To get more informations from the Get Hit Result you could use a print string right before the Cast node and print out the Hit Actor output (maybe use a Get Name / Get Dispay Name to print)

: EDIT :

Back at the PC again. If you print your Hit Actor name you get some more informations about what is happening.

@Pantoth i tested like this and if i clicked on my BP_Object2Click there is nothing output.
I mean HitActor from BreakHitResult output is emtpy

this is my BP_Object2Click:

What Object Types are you tracing for? In my case it was WorldStatic.
Therefore make sure, that your Object Type (under Collision) is set to that equivalent type.

1 Like

@Pantoth Wow its Worked like charm. Thank you very much.
i think you need to merge your answer on single post. it will help others and they will appreciate it.

1 Like

Glad I could help! Hopefully there are no further problems with multiplayer now :slight_smile:
And yeah, good idea, I will edit and merge my posts!

1 Like

@Pantoth yes i modified it for Multiplayer. i will post it soon for other players.

@Pantoth thank you very much!
i modified your BP’s to Multiplayer and it worked:

BP_Object2Click Blueprint:


Player controller:

Character:

Widget:

1 Like