C4 Engine
C4 Engine API Documentation

Interactor::HandleInteractionEvent

Defined in:  C4World.h
Called to handle an interaction event.
Prototype

virtual void HandleInteractionEvent(EventType type, Node *node, const InteractionProperty *property, const Point3D *position = nullptr);

Parameters
type The type of event. See the Controller::HandleInteractionEvent for a list of possible types.
node The interactive node to which the event pertains. It is possible for this to be nullptr.
property The interaction property to which the event pertains. This is nullptr whenever the node parameter is nullptr.
position The object-space position on the interactive node at which the event took place. If the type parameter is kEventInteractionDisengage, then this parameter is nullptr.
Description
The HandleInteractionEvent function is called by the World Manager when an interaction event takes place for a particular instance of the Interactor class. If this function is overridden, it must call the base class counterpart first. An overriding function will typically cause the Controller::HandleInteractionEvent function to be called for the controller attached to the node specified by the node parameter.

The HandleInteractionEvent function only receives the kEventInteractionEngage, kEventInteractionDisengage, and kEventInteractionTrack events. The remaining two event types, kEventInteractionActivate and kEventInteractionDeactivate, should be sent directly to a controller when the user explicitly provides input with the intent to interact with an object.

If an interactive node is deleted after the kEventInteractionEngage event occurs, and the interaction was still engaged at the time of deletion, then the node parameter is nullptr when the kEventInteractionDisengage event occurs for the deleted node. In this case, the property parameter will also be nullptr.

It can be determined whether an Interactor instance is currently engaged with an interactive object by calling the Interactor::GetInteractionNode function.
See Also

Interactor::SetInteractionProbe

Interactor::GetInteractionNode

Controller::HandleInteractionEvent