Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | BOX_Milk |
code:
extends Area2D
onready var player = get_parent().get_node_or_null(“Player”)
var use = false
func _process(delta):
if use == true:
if Input.is_action_just_pressed(“use”):
player.add_child(self)
func _on_wood_body_entered(body):
if “Player” == body.name:
use = true
func _on_wood_body_exited(body):
if “Player” == body.name:
use = false
E 0:00:01.705 add_child: Can’t add child ‘wood’ to ‘Player’, already has a parent ‘Scene’.
<Error C++> Condition “p_child->data.parent” is true.
<Open code C++>scene/main/node.cpp:1282 @ add_child()