Custom Widget Spawner

How to show something other than the standard option menu

Note that the tools demonstrated in this page are accessible from MSquared v20

Experimental - Customers are encouraged to test and use this feature in their experiences, but it may still require some additional support

Overview

When using interactables, you may want to use the standard options menu available but in some cases you may wish to display your own custom widget (such as a visual representation for a vending machine). This page will detail how to create that, by walking you through our example object BP_Example_Interaction_WidgetSpawner.

How it works

Below are the steps to re-create this example object.

  1. Create an Actor you wish to have spawn a widget on interaction

  2. Add the M2_Interactable component

  3. Right click the interactable component -> Add event -> InitializeInteract

  4. If you require the standard interaction menu; Right click the interactable component -> Add event -> OnButtonOptionRequested.

  5. Use InitializeInteract to set ShowMenuOnInteract on the interactable component. Then either open your custom widget or, if needed, dynamically adjust options ready for the standard interaction menu.

  6. If using the standard interaction menu, handle option selected logic in OnButtonOptionRequested.

The Widget itself

It is very important that your widget call CompleteInteractionupon closing, to allow the handler to accurately track it's interaction status.

If you wish your widget to listen to external sources requesting interactions be closed, bind to RequestCloseInteraction on the Interactable Handler.

Where To Find It

Our example of this can be found in the Approachability and Feature Test Gyms, or directly via

/Plugins/M2Unreal/JunoSkypark/Content/ObjectInteraction/Examples/CustomWidgetSpawner

Last updated