Hello, I'm getting an error when reparenting non-child node A to child node B and back again. The really weird thing, though, is that it only happens if I'm looking in a certain direction (I think) the second time. I have absolutely no idea what the cause of this could be. The error in question:
<C++ Source> scene/main/node.cpp:120 @ _notification()
<Stack Trace> Player.gd:61 @ body_pickup()
Player.gd:52 @ _physics_process()```
Relevant code (full version in project):
@onready var pickup_position = $Camera3D/Pickup
var ball: RigidBody3D
var cooldown = 1.0
26 func _physics_process(delta):
...
48 if Input.is_action_just_pressed("shoot"):
49 if ball:
50 ball.freeze = false
51 ball.apply_central_impulse(camera.global_transform.basis.z * -7)
52 ball.reparent(get_parent())
53 ball = null
54 cooldown = 0.5
58 func body_pickup(body):
59 if body is RigidBody3D:
60 if cooldown <= 0:
61 body.reparent(pickup_position)
62 body.global_position = pickup_position.global_position
63 body.freeze = true
64 ball = body
I've attached a project that demonstrates my problem to this thread (Godot Version 4.2.1). Is this a problem with my programming, or with the engine?
Thank you for your time :-)