🤝ODK Interactable Component

Documentation for ODK Interactable Component

The ODK Interactable component is a lightweight component similar to the M2Interactable component that can be dropped onto an actor to unlock user interaction.

BPC_ODKInteractableBase

The BPC_ODKInteractableBase component should not be used on it’s own. Instead, child actors can be created to handle the functionality of the interaction when the user approaches, looks at and interacts with the actor using an input binding.

The base class contains the exposed variables necessary to tailor the interaction for each actor.

Input Mappings

The input mappings variables allow the user to assign an Enhanced Input Mapping Context and Enhanced Input Action to the interactable. This is the input binding that activates the interaction when pressed. For example, an input mapping with a keyboard shortcut of F is used by default. The user is required to be within range of the interactable actor and looking at the actor and then when pressing F on the keyboard, the interaction will trigger.

Interaction Radius

When the Interactable component is spawned, it spawns a sphere collider to handle AuthClient overlaps. The Interaction radius variable determines how big this sphere collider is. This can sometimes be difficult to visualise and tailor for each interactable actor, which is where the debug variable below is useful.

Debug Overlap in Editor

The Debug Overlap in Editor variable shows the sphere collider at runtime (editor only.)

Overridable Events

AuthClientOverlap

Called when the authoritative client overlaps the spawned sphere collider

AuthClientOverlapEnd

Called when the authoritative client leaves the overlap of the spawned sphere collider

InteractableActiveStart

Called when the current Interactable is active. This is triggered when:

  • The component is enabled

  • The sphere collider is overlapped

  • The current actor is the closest interactable within the focus threshold

InteractableActiveEnd

Called when the Interactable is no longer the active interactable (see above)

Event Dispatchers

The event dispatcher bindings should be used by the owning actor to implement the functionality.

OnOverlapStart

Called on overlap, whether it is the active interactable or not

OnOverlapEnd

Called on overlap end, whether it is the active interactable or not

OnInputStart

Called when the interactable is the active component and the Input mapping is called

OnInputEnd

When input is ended, usually on key up.

BPC_ODKInteractable_Widget

BPC_ODKInteractable_Widget serves as an example class of how to derive from BPC_ODKInteractableBase.

The user can define a widget and an offset along with WidgetVariables that are sent to the spawned widget using the BPI_ODKInteractable_Widget interface.

When the Interactable is active (see above), the widget will be displayed. The example widget gets the key binding from the Input mapping to display this on the widget.

BP_ODKInteractablesManager

The BP_ODKInteractablesManager must be in scene in order to use the BPC_ODKInteractable components.

The manager handles which of the interactables is the active interactable along with if the interactable is in focus.

Several settings can be set on the InteractablesManager by calling the setter functions from other actors.

SetAngleThreshold

Default: 20

This function sets the angle at which an interactable is considered “In focus”.

The default setting is 20°, which means that the interactable has to be within 20° of the center of the camera.

SetUpdateFrequency

Default:0.2

This function sets the update frequency of the angle threshold check.

When the player is overlapping 1 or more interactables a timer event is triggered that updates at this frequency to check which overlapped interactables are in focus.

SetCheckInteractablesAgainstVisibilityLinetrace

Default: True

When the angle check is conducted, with this variable true, it will also check against a line trace. The reason for this is to stop interactables that are behind walls from triggering. This does however mean that an interactable has to have collision for it to be activated. This is usually OK with actors that contain static meshes, but something to keep in mind when designing new Interactable actors.

Setting up an Interactable Actor

To create a new Interactable actor, create a blueprint actor as normal and drop an ODKInteractable component on it. Set up the interactable radius and the input mappings in the details panel of the component.

Next, use the Events to create the functionality of the interactable by clicking on the plus icon in the details panel

Last updated