Hey party people, I'm having some trouble with 'despawning' an object from one of my scenes with queue_free(). Keep getting an error "Invalid call. Nonexistent function 'queue_free' in base 'Nil"."
The ball var should be accessible by the _on_DeadZone_body_entered() function, so I'm not sure what I need to adjust to make queue_free() work...any help would be appreciated!!!
Code is attached as screenshot as well as typed out below!
====CODE START====
extends Node
var ball_prefab = preload("res://_scenes/Ball/Ball.tscn")
var ball
func _ready():
pass
func _physics_process(delta):
if Input.is_action_just_pressed("launch"):
if $Player.launchable():
ball = $Player.launch_ball(ball_prefab)
add_child(ball)
else:
print("Cannot launch ball")
func _on_DeadZone_body_entered(body):
ball.queue_free()
$Player.reset_ball()
====CODE END====