+1 vote


i've used godot for some time, but still am mostly a nooblet

having set up a lil tank, and getting it to shoot lazers, i proceeded to make them disappear upon hitting an obstacle. strangely enough, something goes wrong the moment body_enter signal is called.

i get this error (it doesn't crash the game thou):
error calling method from signal (body_enter), expected 0 arguments

it's really weird because the brackets in the "_hit()" function are empty (i assume this is where arguments usually reside?)

code, the object is an Area2D (sorry for raw paste, but i cant get the code frame thingy to work)

func ready():

func process(delta):

func hit():

i used the body_enter signal many times in the past and this has never happened, so am quite confused. :<

in Engine by (15 points)
Please, use the "code" button on the QA editor, don't just paste it. To get it working, you should select your code, and then press it. (also, this is markdown, so if you just indent those lines with four spaces..)

1 Answer

+2 votes

body_enter signal has a parameter which hit the body.

body_enter( Object body )

So, you should have parameter at func _hit()

func _hit(target):
by (9,796 points)
haha thanx!

i forgot about having to write 'body' beetwen the brackets... although then shouldn't the error say 'expected 1 argument' instead of zero arguments? xD
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 Frequently asked questions and 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 [email protected] with your username.