Converting an M2Interactable to ODKInteractable
Last updated
Last updated
The M2 Interactable component is scheduled for deprecation. To ensure your interactable components remain functional, it's essential to migrate from the M2 Interactable to the ODK Interactable.
This guide focuses on converting an existing M2 Interactable to the ODK Interactable. If you're implementing interactions for the first time, please refer to the documentation for BPC_ODKInteractable here
Step 1: Inspecting the Existing Blueprint
Open the Blueprint: Upon opening BP_Approachability_TestInteractable, you'll notice a component called M2_Interactable.
Key Variables in M2_Interactable:
Interaction Range: Determines how far the player can be from the actor for the interaction prompt to appear.
Options Section: Specifies the interaction prompt that will be displayed when the player approaches the actor.
Existing Event: The Blueprint includes an event named OnButtonOptionRequested, which is triggered when the user interacts with the actor.
Step 2: Preparing for the Conversion
Before replacing the M2_Interactable component, note the following:
Record the current Interaction Range value, as it will need to be reconfigured in the ODK component.
Take note of the Options Section, including the interaction prompt text, to replicate it in the new component.
In this example, we will use the BPC_ODKInteractable_Widget component, which extends from BPC_ODKInteractableBase. This component provides the ability to customize the interaction prompt through a widget, making it more flexible and adaptable than the M2 version.
Step 1: Adding the BPC_ODKInteractable_Widget Component
Open the actor you wish to update (e.g., BP_Approachability_TestInteractable).
In the Components panel, add the BPC_ODKInteractable_Widget component to the actor.
Locate the Config section in the component's details and configure the following key variables:
Interaction Radius: Set this to the desired range where the interaction prompt will appear (similar to the Interaction Range in the M2 version).
Step 2: Configuring the Interaction Prompt
In the Widget Variables section:
Define the data you want to send to the widget. This uses the BPI_ODKInteractable_Widget interface to pass information directly to the widget without needing to extend a base widget class.
For this example:
Create a Map with:
Key: Title
Value: "Randomize Colour" (type: String)
This configuration ensures that the interaction prompt displays the text "Randomize Colour" when the user approaches.
Step 3: Customizing Input Contexts and Actions
Unlike the M2 version, the BPC_ODKInteractable_Widget allows you to define:
Mapping Context: Specify which input context to use for interactions.
Input Action: Select the specific input action that triggers the interaction.
This flexibility ensures that the widget automatically updates based on the input hardware (e.g., switching between keyboard/mouse and gamepad). Configure these settings in the Input section of the component details.
Also on the BPI_ODKInteractable component, there are various events exposed that allow us to customise the interaction.
More information on these events can be found in the ODKInteractable Documentation
To update this actor we are going to implement the OnInputStart event which fires when the user is in range, looking towards the actor and presses the interaction action button.
To implement the event click the + button.
Now that we have the event, connect it to the Randomise Colour function, just as the M2Interactable version is
We now just need to clean up the M2Interactable events and component and the conversion is complete.
Drop the new actor into your scene and approach the actor. When you are within the interaction radius and looking towards the actor you will see the interaction prompt. Press the relevant input key and the cube will change colour.