Home › How do I…? › How to make an object clickable by mouse, laser or touch

How to make an object clickable by mouse, laser or touch

Advanced Framework Pro handles mouse click, VR laser and fingertip touch with one component, BPC_Interaction_Select, so you bind one event and get all three input methods. By the end of this you will have an object that highlights on hover and fires an event when clicked, pointed at with a laser, or touched with a fingertip.

At a glance

Your actor
└─ BPC_Interaction_Select   Highlight Class, Highlight Color, Select Sound (optional),
                            Relevant Components = tag of the clickable meshes (optional)
Event: On Select (Source Info says which pawn, hand and ability)
Veto:  Interface_Select › Override = true, Is Selectable = false
Laser end point: Select_HitLocationOverride
Pawn side (shipped pawns have it): BPC_PawnAbility_Select;
VR controllers: BPC_ControllerAbility_Hand_Laser / BPC_ControllerAbility_Hand_Finger

Steps

  1. Open the actor Blueprint and add a BPC_Interaction_Select component.
  2. Set Highlight Class and Highlight Color.
  3. Optionally set Select Sound.
  4. In the Event Graph, bind to the component's On Select delegate.
Adding the select interaction
howto_selectable_01.pngAdding the select interaction
Adding the select interaction
The object selected in play, highlight active
AFS_UX_Select_result.pngThe object selected in play, highlight active
The object selected in play, highlight active

Notes

If the actor has several meshes and only some should be clickable, tag those components and set Relevant Components to that tag.

To veto selection conditionally, implement Interface_Select and return Override = true with Is Selectable = false.

To make a laser terminate somewhere other than the raw trace hit — the centre of a control, say — implement Select_HitLocationOverride.