Godot Version
4.5
Question
(I’m sure Im just missing something but here goes :D)
My interactable object works, it disappears, it prints what it needs to in the debug window, but there are three problems that ive tried to fix and couldn’t:
- You can interact with the object from wherever you are in the level. I need it to just fit the object.
- The label pops up in the corner of the game window and stays. It doesn’t show up on top of the object when you get close, like its supposed to. Although, this could just be because I’m doing this in 3D - I deleted the node, but if anyone knows how to make those work in 3D that would be great

- The interactable object does not become uninteractablle, when i press E more than once it keeps printing ‘memory’.
Interact Script:
extends Area3D
@export var interact_name: String = ""
@export var is_interactable: bool = true
var interact : Callable = func():
pass
interactable_instance script:
extends Node3D
var current_interactions := []
var can_interact := true
func _input(event: InputEvent) -> void:
if event.is_action_pressed("interact") and can_interact:
if current_interactions:
can_interact = false
await current_interactions[0].interact.call()
can_interact = true
func _process(_delta: float) -> void:
if current_interactions and can_interact:
current_interactions.sort_custom(_sort_by_nearest)
func _sort_by_nearest(area1, area2):
var area1_dist = global_position.distance_to(area1.global_position)
var area2_dist = global_position.distance_to(area2.global_position)
return area1_dist < area2_dist
func _on_area_3d_area_entered(area: Area3D) -> void:
current_interactions.push_back(area)
func _on_area_3d_area_exited(area: Area3D) -> void:
current_interactions.erase(area)
And heres my VHS tape/object script:
extends AnimatableBody3D
@onready var interactable: Area3D = $Interact
func _ready() -> void:
interactable.interact = _on_interact
func _on_interact():
hide()
interactable.is_interactable = false
print("Memory")
You don’t seem to check the value of can_interact when running the interaction logic, so the interaction function will always run. You should only run the function if the player should be able to interact with the object.
For the label, were you using a 2D or a 3D one?
Ooooooh, how do i add that paramater?
And i was using a green one, although i think it was 2d
You can pass parameters to the call function.
If you want the label to appear in a 3d environment, you need to use a 3d label.
1 Like
okay 
I think i have the right code (i did take it from you so thank you very much!!), but how do i set the max distance?
extends Area2D
@export var interact_name: String = ""
@export var is_interactable: bool = true
@onready var Player = $"Player (LowPoly For Game)"
var interact : Callable = func():
if Player.global_position.distance_to(global_position) > max_distance:
is_interactable = false
The max distance is whatever you want it to be, you set it yourself?
ooooh, wait, i just put the number i want right after the ‘:’?
i thought i would have to put another thing, like coordinates or something :,D
thats why i was confused sorry
when i put it in now, it doesnt wrk, so i think i misunderstood
extends Area2D
@export var interact_name: String = ""
@export var is_interactable: bool = true
@onready var Player = $"Player (LowPoly For Game)"
var max_distance = 1
var interact : Callable = func():
if Player.global_position.distance_to(global_position) > max_distance:
is_interactable = false
1 Like
The distance uses pixels as units. If you have 1 as the max distance, it’s 1 pixel.
1 Like
okay 
but now the paramater wont work, it still iteracts even if im over the 100 pixel limit
extends Area3D
@export var interact_name: String = ""
@export var is_interactable: bool = true
@onready var Player = $"."
var max_distance = 100
var interact : Callable = func():
if Player.global_position.distance_to(global_position) > max_distance:
is_interactable = false
It might be because you don’t check is_interactable anywhere?
But I’m not 100% sure, your code structure is confusing to me. Is there a reason you have
await current_interactions[0].interact.call()
instead of something like the below?
current_interactions[0].interact()
1 Like
I figured it out thank you 
(I had it capalized and then a few other confusing things i put in a different, dedicated forum post)
But you really did help so thank you for that!!
1 Like