notme21
notme21

Reputation: 47

Error on function call for Area2D randomly occurs

I have created a system, within which I am instancing kinematic bodies (2D). These have scripts attached. When I call the functions within these, all is GENERALLY okay. However randomly, with wildly different wait times for it to happen (sometimes it never does), the system will crash, saying that the function, that has been working fine, is does not exist within Area2D. I have no clue why this can happen, can anyone give me any help with this.

The actual error code Invalid call. Nonexistent function 'move' in base 'Area2D'

Thanks

Upvotes: 0

Views: 226

Answers (1)

Andy K
Andy K

Reputation: 7282

Add check for method existence before you call method.

Let's say you call move method for obj variable (replace it with your own). Now call to the move method should look like this:

if obj.has_method("move"):
    obj.move()

Docs

Upvotes: 1

Related Questions