Concepts

Interactions

How characters interact with objects.

As players move around in a game, they have to be able to detect when they're near an object they can interact with. For example: A player character walking up to a storage box, which they can open in order to access its contents.

This is the responsibility of the Interactor and Interactable component pair. These two components operate in diegetic world space. In other words, they're 2D/3D specific.

In a 3D game, it's common to let the player aim at an object they want to interact with using a RayCast3D. The Inventory System does not currently include 3D interaction components.

2D Components

In 2D games, it's often sufficient to make interactions available by proximity. This is achieved by detecting when Area2D objects overlap.

call a function
call a function
GGInteractable2D
(Area2D)
GGInteractable2D...
Storage Box
(StaticBody2D)
Storage Box...
GGInteractor2D
(Area2D)
GGInteractor2D...
.interact()
.interact()
Player Scene
(CharacterBody2D)
Player Scene...
.interact(self)
.interact(self)
GGInteractable2DStrategy
(Resource)

Determines the type of interaction
GGInteractable2DStrategy...
Strat
Strat
Text is not SVG - cannot display

Interactor2D

The GGInteractor2D component is added to a character to detect when that character is within range of an interactable.

Interactable2D

The GGInteractable2D component is added to any object that a character can interact with. It has two purposes:

  1. To be able to be detected by a character's interactor component.
  2. React to the character requesting interaction, which is determined by the strategy it is configured with.

Interactable2D Strategy

When a character interacts with an object, the interactable's GGInteractable2DStrategy class determines what happens.

For example:

  • When interacting with a lamp, the character toggles the light switch to turn the light on and off.
  • When interacting with a storage box, the character opens the Inventory Transfer screen to exchange items.

For 2D games, the GGInteractable2DStrategyInventory opens the object's inventory so that items can be exchanged.

© 2023 — 2025 GodotBuilder. All rights reserved.