Skip to content

Instantly share code, notes, and snippets.

@kingthrillgore
Created April 22, 2026 06:05
Show Gist options
  • Select an option

  • Save kingthrillgore/b85f203f16fda5c94716e62d6d543a6d to your computer and use it in GitHub Desktop.

Select an option

Save kingthrillgore/b85f203f16fda5c94716e62d6d543a6d to your computer and use it in GitHub Desktop.
A base class for Interactive elements
# Interactable.gd
# Base class for anything the player can interact (frob) with.
class_name Interactable
extends Node3D
# Signals
## Emitted when the player interacts with this object. Includes [param interactor].
signal interacted(interactor: Node)
# Public Methods
## Implements Interactable, which should be called as [code]super.*[/code] by your child class definitions
## of [code]interact()[/code] that override any interaction logic. When this is fired,
## it will emit [signal interacted].
func interact(interactor: Node):
interacted.emit(interactor)
## Returns basic interaction text. Is not being used.
## TODO: Evaluate if this should be changed to, or also implement method
## `get_interaction_prompt` due to UX reasons
func get_interaction_text() -> String:
return "Interact [F]"
## Returns whether the player can interact with this object, right now always returns [code]true[/code].
func can_interact(interactor: Node) -> bool:
return true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment