How do I fix "Invalid call. Nonexistant function 'destroy' in base 'Node2D'"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AshTheKindra

So I’m trying to make a 2D platformer that plays like Super Meat Boy in Godot. I’m currently trying to make the collision detection with an obstacle work. However when I try to get it to work, I get “Invalid call. Nonexistent function ‘destroy’ in base ‘Node2D’”. I have no clue how to fix it. Here is the code for the obstacle:

extends Area2D

func _ready():


func _physics_process(delta):
if $RayCast2D2.is_colliding():
if $RayCast2D2.get_collider():
var player = get_parent().get_parent().get_node(“/root/Node2D/Player/Beepo”)

func _destroy():

:bust_in_silhouette: Reply From: timothybrentwood

The destroy() function needs to be defined in a script attached to the node located at /root/Node2D/Player/Beepo if you want to call player.destroy().

Otherwise just call destroy() since it’s defined in the script you pasted and it’s not doing anything related to the player node.

Ah ok, thank you.

AshTheKindra | 2021-05-18 23:49