point at static mesh and click to open a specific UMG


How can I make an action (event) that when I point at a certain static mesh and use the key “F” (for instance), a specific UMG (UMG that I created specifically for that static mesh) opens up.


On the Mesh Blueprint, try finding an event ‘onCursorOver’ or ‘OnMouseHover’, you have something like this.

When hovering in, get your character, tell a boolean “isHovering = TRUE”, when hovering out, tell the boolean “isHovering = FALSE”.

When the player presses F, checks if isHovering == TRUE, if so, sets the visibility of your widget to visible.

Tada :slight_smile:

Thank you for your fast reply!
Could you send a printscreen of the mesh blueprint so it will be more clear to me.

Thank you again.

Well, one way would be making a new Actor that has a StaticMeshComponent.
Call it, for example, “InteractiveMesh”. You can then create a variable of Type “UserWidget (CLASS)” (the purple one) in it
and use that later for the “Create Widget” node.

Now you do a simple line trace in your Character when pressing F. Once you hit something, you cast the “HitActor” of the “HitResult (break it)”
to “InteractiveMesh”. Now you need some kind of CustomEvent in that “InteractiveMesh” actor that creates a widget and adds it to the viewport.

You will want to call that event then in your character after casting the hitactor to your actor class.

You can then place multiple “InteractiveMesh” actors in your level, change the Mesh of each and also change the Widget class that should be used via that
variable. Make sure to set the Variable of the UserWidget to be “EDITABLE”.

please could you make a screen grab from the blueprint - if I see it as a picture it will be much more clear