Firewatch style context sensitive interaction

Well I have the same system even a better one and here is an additional breakdown of approach in addition to @lordlolek 's

1- InteractionActorComponent: Create a component with all variables you need for interaction. Such as InteractionState(Active, Inactive, Depleted), IntName,IntAction (use pickup, i use string to be flexible however you can go with enums),ntID, bIsShown, InteractionDistance (close,normal, far) etc.

2- InteractionScanner: Create a scanner, like a sphere collider that detects and strips the InteractionActorComponents in a radius. You can use a custom collision channel too if you prefer. Interaction scanner does 2 things: (1) Decide which interaction in radius should be shown to player. Distance, angle, interactions state matches , if there is an object in between etc… (2) Detect how player interacts with it, is button pressed etc for that interaction.

3-InteractionProcessor : I use a subsystem for it but can be something else. Knows which interactions are available for a player at a gameplay moment. Bridges the communication between player and interaction component. EX: player presses button, subsystem catches press event and calls to interaction component to do its job, component has an event as interacted and depending on the component settings, opens a door, pulls a lever, opens a dialog etc.
Also I do UMG operations over here to show a designated ui for that player with whatever interaction is prioritized and only umg ticks for visibility reasons.
You can do context sensitive action here after interaction event received what animation etc player should make since we know its interacted, who interacted and what interacted with. If you implement a socket or a box into actor component you can tell animation invkinematics hand/finger to that location.

This way, interaction doesn’t care about what is being interacted. If something is interacted its between InteractionActorComponent and whatever its listening its commands, like a door.

Couple of advantages of system.

  • Its an agnostic system so can be extended, scanner can scan many more things if wanted around player.
  • Since its independent, its much more easier to use and integrate
  • Much more easier to localise.
  • Can have different interaction conditions, like player is drunk you can lower interaction distance etc :slight_smile:
  • Much more flexible interms of interaction control, conditions like, no interaction behind a glass wall, interaction through a fence, no interaction behind the object,
  • Multiplayer control, if object interaction by one player put state inactive so other clients can’t interact etc. or can interact.
  • and many more.