0 votes

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(Mod.gd)::set_monitoring': 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()]
    $AnimationPlayer.play("mobrotate")

func _on_VisibilityNotifier2D_screen_exited():
    queue_free()

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

Please help me fix this problem

Thanks you

Godot version Godot 3.4 standard version
in Engine by (28 points)
edited by

1 Answer

0 votes
Best answer

monitoring is a property of Area2D: https://docs.godotengine.org/en/stable/classes/class_area2d.html?#class-area2d-property-monitoring

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)

by (382 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.