0 votes

Does anybody know why this error is happening:

E 0:00:05.712 emitsignal: Error calling method from signal
'timeout': 'KinematicBody(Player.gd)::recoil': Method expected 1
arguments, but called with 0.. <C++ Source> core/object.cpp:1242 @
emit
signal()

This is the code which is probably the problem:

func weapon_functions(delta):
# Call recoil every time the shoot animation is played
var timer = Timer.new()
if player_shooting == true:
    timer.set_wait_time(current_weapon_recoil_time)
    timer.set_one_shot(false)
    timer.connect("timeout", self, "recoil")
    add_child(timer)
    timer.start()
else:
    timer.stop()


recoil(delta)
in Engine by (15 points)

Is the code suppose to be this?

func recoil(delta):
    pass

1 Answer

+1 vote
Best answer

Your recoil function is expecting an argument to be passed into it (delta). However, that's not being passed in due to the way you've wired the timeout function. If you don't need the delta argument, remove it from the function definition. If you do need it, then pass it in like:

timer.connect("timeout", self, "recoil", [delta])
by (19,298 points)
selected by

Thank you :D

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.