Created
April 22, 2026 06:05
-
-
Save kingthrillgore/b85f203f16fda5c94716e62d6d543a6d to your computer and use it in GitHub Desktop.
A base class for Interactive elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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