Please help me fix this problem: _call_function: Error calling deferred method: 'RigidBody2D

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

I try to make a game like first game in Godot tutorial
When i test the game, debug show below error:

E 0:00:11.372   _call_function: Error calling deferred method: 'RigidBody2D(': Method not found..<C++ Source>  core/message_queue.cpp:243 @ _call_function()

and when my enemies spawn it was stuck in the edge of screen.
below is my code:

extends RigidBody2D

export (int) var MIN_SPEED
export (int) var MAX_SPEED
var mob_types = ["mobb", "mobg", "mobr", "moby"]

func _ready():
	$MobSprite.animation = mob_types[randi() % mob_types.size()]

func _on_VisibilityNotifier2D_screen_exited():

func collected():
	# limit collision to single time
	call_deferred("set_monitoring", false)

Please help me fix this problem

Thanks you

:bust_in_silhouette: Reply From: spaceyjase

monitoring is a property of Area2D: Area2D — Godot Engine (stable) documentation in English

Your script extends RigidBody2D, which is not an Area2D. You likely mean to get another node and set its property; e.g. $Area2D.call_deferred("set_monitoring", false)

Thanks you for your help.
I don’t know how to fix this, so I deleted it, now it not show error :frowning:
But i : my enemies stuck at 2d spawn path. it is just spawn only a not move
Do you know how to fix this.

tuan | 2021-11-30 12:28