The body_entered
signal only fires when a body
just enters the area therefore the player would need to be pressing the mousebuttonL
input as they enter in order for your code to work. Something like this should work, just connect the body_exited
signal:
func _input(event: InputEvent) -> void:
if get_parent() == get_node("area"): # this is probably what you want to do
set_process_input(false) # but feel free to change it if not
elif event.is_action_pressed("mousebuttonL"):
print ("stone ready")
var new_parent = get_node("area")
var source = get_node("deco/steiin2")
get_parent().remove_child(source)
new_parent.add_child(source)
func _on_Area2_body_entered(body):
if body.get_name() == "stone":
set_process_input(true)
func _on_Area2_body_exited(body):
if not is_processing_input():
pass
elif body.get_name() == "stone":
set_process_input(false)
Also something of note: if the mousebuttonL
input is used in another script, the input may get eaten and not echoed to this script.