#Invalid argument for "connect()" function: argument 2 should be "Callable" but is "res://Sprite2D.gd

2 messages · Page 1 of 1 (latest)

raw acorn
#

link: https://docs.godotengine.org/es/latest/getting_started/step_by_step/signals.html

I am following the tutorial to the letter, but I always keep getting this error, I consulted it with gpt chat to find a solution but nothing. it's driving me crazy

code:
extends Sprite2D

var speed = 400
var angular_speed = PI

func _ready():
var timer = get_node("Timer")
timer.connect("timeout", self, "_on_Timer_timeout")

func _process(delta):
rotation += angular_speed * delta
var velocity = Vector2.UP.rotated(rotation) * speed
position += velocity * delta

func _on_Button_pressed():
set_process(not is_processing())

func _on_Timer_timeout():
visible = not visible

errors: Línea 8:Invalid argument for "connect()" function: argument 2 should be "Callable" but is "res://Sprite2D.gd".
Línea 8:Cannot pass a value of type "String" as "int".
Línea 8:Invalid argument for "connect()" function: argument 3 should be "int" but is "String".

lilac prism
#

Change the timer.connect(...) line to

timer.connect("timeout", _on_Timer_timeout)

note that there are no () after _on_Timer_timeout