TabletopInteraction
A protocol for objects that manage the entire flow of players interacting with equipment.
Declaration
class TabletopInteractionOverview
Conform to the TabletopInteraction.Delegate protocol to take an appropriate action, depending on the equipment and the phase of the interaction. For example, move equipment or toss a die when a gesture ends.
struct MoveInteraction: TabletopInteraction.Delegate {
func update(interaction: TabletopKit.TabletopInteraction) {
let equipment = interaction.value.controlledEquipmentID
guard let destination = interaction.value.proposedDestination else {
return
}
if interaction.value.phase == .ended {
interaction.addAction(.moveEquipment(matching: equipment, childOf: destination.equipmentID, pose: destination.pose))
}
}
}To get information about the equipment that the interaction applies to, use the value property. To get the phase of the interaction or gesture, use the Value gesturePhase or phase properties.
Then execute actions — for example, move equipment when the phase ends — using the addAction(_:) or addActions(_:) method.
To start an interaction programmatically, use the TabletopGame startInteraction(onEquipmentID:) method.
Topics
Performing actions
TabletopInteraction.DelegateTabletopInteraction.TossOutcomeaddAction(_:)addAction(_:)addActions(_:)toss(equipmentID:as:linearVelocity:angularVelocity:)end()cancel()
Getting the value of the interaction
Setting information about the equipment and pose
Managing the interaction destination
setConfiguration(_:)TabletopInteraction.ConfigurationTabletopInteraction.AllowedDestinationsTabletopInteraction.DestinationsetAllowedDestinations(_:)
Getting the interaction identifier
Determining the dead zone
Handling collision behavior
TabletopInteraction.ConstantsTabletopInteraction.CollisionTargetsTabletopInteraction.DirectPickupBehaviorTabletopInteraction.DirectInteractionConstantsTabletopInteraction.IndirectRotationAlignmentBehaviorTabletopInteraction.IndirectInteractionConstantsTabletopInteraction.HoverAlignmentBehaviorTabletopInteraction.HoverAlignmentSourceTabletopInteraction.ProgrammaticInteractionConstants