Interactables
Most interactables can derive from BaseInteractable. Agents with ProdigyAgentInteractor will scan their given trigger area for objects with the IInteractable interface. "Hover" functionality is built into this base class, while the Interact() functionality must be added by the derived class.
Any IInteractor can Interact with IInteractable interfaces. Implementing Interactables in your project should be pretty straightforward. You can reference the example interactable components for reference.
For example, here is InteractabeToggle and its Interact() function implementation.
public override void Interact(IInteractor interactor)
{
if (!CanInteract(interactor)) return;
m_isOn = !m_isOn;
PlayCurrentAnimation();
if (m_isOn) OnToggledOn?.Invoke();
else OnToggledOff?.Invoke();
interactor.EndInteraction(this);
}This is quite simple, and just fired events that are exposed in the inspector. Other interactable features are more complex, and you can write your own to do just about anything you want when the player deliberately interacts with it.
An interaction's lifetime begins when the Interactor initiates the interaction. When it does, it is flagged as Busy and cannot do certain things - specifically, other interactions, until it is no longer Busy.
To exit being busy, the interactable that the agent interacted with must handshake back to signal the end of the interaction via interactor.EndInteraction(this). This will free up the agent again and make it no longer be considered Busy .
Last updated
Was this helpful?