1. Getting Familiar with the C++ Components
The interaction system is defined in the C++ with exposed Blueprint functions to further fine-tune the interaction system:
List of relevant C++ classes:
- GloveController (Actor Component)
- Forte_Interactable (Actor Component)
- Forte_PickUpObject (Actor Component)
- Forte_TurnKnob (Actor Component)
2. GloveController and Forte_Interactor
- Each GloveController Actor Component contains a Forte_Interactor object.
- The GloveController sets up the OverlapBegin and Overlap End callbacks on each of the Finger Capsule Colliders in CreateDataGlove function.
- The Finger Capsule Collision Components’ OverlapBegin and Overlap callback functions triggers the Forte_Interactor to add or remove a Forte_Interactable from an available list of grabbable objects.
- The Forte_Interactor calculates a grab based on the selected fingers and a grab threshold.
- The selected fingers for grabbing and the grab threshold can be set in the Interactable Blueprints if they contain a derived Forte_Interactable Component.
- Since Forte_Interactable exposes Setup functions to the Blueprints, other Interactable classes (Forte_PickUpObject, Forte_TurnKnob, etc) inherit and utilize those functions.
- When an object is grabbed or released the Forte_Interactable grab events are triggered.
3. Forte_Interactable and Deriving New Interactable Actor Components
The Forte_Interactable is the base Actor Component for deriving other Interactables that require grabbing. For example, Forte_PickUpObject and Forte_TurnKnob inherit properties and functions from Forte_Interactable.
- Forte_PickUpObject requires grabbing physics-simulated objects and toggling the Hand Blueprint finger capsule collision components when throwing.
- Forte_TurnKnob defines a Knob Actor that acts at the parent actor to the hand when grabbing and rotating the knob.
When creating a new type Forte_Interactable the virtual Grab Events need to be defined in the child class, which are then given specific functionality based on the desired utility of the interactable (such as the 2 examples above).
Below is an example of the EnterGrab and ExitGrab functions defined in Forte_PickUpObject:
- The Poses class is an object created in the GloveController.
- When a Forte_Interactable object is grabbed the user can optionally add a pose that the hand lerps to.
- The are a few sample C++ Poses functions defined already, which can be added to for setting precise finger rotation amounts (0-1.0f).
- The Forte_Interactable contains a Blueprint function for setting the grab pose, which the next section will cover.
5. Interactable Blueprints
The Unreal SDK provides some Interactable Blueprints to get started. Some of the Interactable Blueprints like the Button and Lever don’t require adding the Forte_Interactable derived Actor Components, because they don’t require grabbing. These act more as Blueprint examples for showcasing behavior that can be defined when a finger collision component overlaps a collision component in an interactable.
These are located in DataGloveSDK Content/Blueprints/Interactables subfolder:
Functionality that utilizes grabbing behavior can be created by inheriting from the abstract C++ class Forte_Interactable Actor Component. As an example, both Forte_PickUpObject and Forte_TurnKnob utilize a GrabEnter event and GrabExit event to define functionality for interactive behavior.
PickUp_Cube Bluerpint Example Setup:
- A Forte_PickUpObject Actor Component is added in the Blueprint Component menu
- On BeginPlay event a few setup requirements are added to further define the grabbing behavior
- SetFingersUsedToPickup node: sets finger used in grab calculation
- Set Pick Up Threshold node: A value between 0 and 0.5 where a higher threshold makes it so a larger bend is needed to trigger the EnterGrab event.
- Set Collision Components node: This sets the physics collider component and hover collider component used for grabbing.
- Set Pose node: This creates a pose the hand lerps to when grabbing an this specific object.
- No Pose
- Freeze Selected (freezes fingers that are colliding with the object)
- Freeze All
- Turn on Default Collision Haptics node: turns on haptics when an interactable is touched and when a grabbed object hits another object