Skip to main content

PlayerInteractionPoint

A modular, network-aware component that enables interaction zones within the game world. When a player enters the collider area, it can dynamically offer contextual interactions, including support for ownership validation and extensibility through external providers.

public class PlayerInteractionPoint : NetworkKCCProcessor, IPlayerInteractionProvider

๐ŸŽฎ Purposeโ€‹

This script defines an interaction hotspot that:

  • Activates when a PlayerActor with authority enters its collider.
  • Presents a list of available interactions.
  • Filters interactions based on ownership if needed.
  • Supports extending interaction logic via IPlayerInteractionProvider.

๐Ÿ”‘ Key Membersโ€‹

interactionsโ€‹

Type: PlayerInteraction[]
Description: Core interaction list directly assigned to this point.

interactionColliderโ€‹

Type: Collider
Description: Collider that defines the interaction trigger area.

_sourceNameโ€‹

Type: string
Description: Label for debug/UI reference.

externalInteractionProvidersโ€‹

Type: MonoBehaviour[]
Description: Optional external providers that implement IPlayerInteractionProvider for dynamic logic injection.

ownershipProviderโ€‹

Type: OwnershipProvider
Description: Optional logic module to restrict interactions to owning players.


๐Ÿง  Key Behaviorsโ€‹

OnEnter(KCC kcc, KCCData data)โ€‹

Registers available interactions with the entering PlayerActor.

OnExit(KCC kcc, KCCData data)โ€‹

Removes registered interactions when the actor exits the zone.

GetInteractions(PlayerActor actor)โ€‹

Builds and filters the list of interactions based on:

  • Static list
  • External providers
  • Ownership rules

Enable() / Disable()โ€‹

Manually toggle the interaction collider and isActive state.

Spawned() / Render()โ€‹

Initial setup and change detection for enabling/disabling the collider via NetworkBool.


๐Ÿงฉ Interfacesโ€‹

IPlayerInteractionProviderโ€‹

public interface IPlayerInteractionProvider {
PlayerInteraction[] GetInteractions(PlayerActor actor);
}

Allows external scripts to contribute dynamic interactions.

IOwnershipProviderโ€‹

public interface IOwnershipProvider {
bool CheckOwnership(PlayerActor actor);
}

Used to verify if a player can access ownerOnly interactions.


๐Ÿ”— Structs & Typesโ€‹

PlayerInteractionโ€‹

Represents a single interaction option.

public struct PlayerInteraction {
public string Label;
public UnityEvent<PlayerActor> Action;
public InputProvider.InputButton Button;
public PlayerInteractionPoint point;
public bool ownerOnly;
public bool dismissAfterUsage;
}

๐Ÿงช Editor Utilitiesโ€‹

  • OnValidate(): Automatically finds a collider if none is set.

โœ… Usage Tipsโ€‹

  • Attach this to a GameObject with a Collider (set as trigger).
  • Define interactions via the inspector or via external components.
  • Use OwnershipProvider to restrict specific options.

This component is ideal for NPCs, terminals, doors, or any other in-world interactive element.