"Connect()" parse error reading as a string

I want a delay in my script where the inertia of a jumping character decreased when wall jumping and they start to slide down the wall.

However I’m new to GDScript script and really struggling with coding a delay. Can anyone identify what is wrong here?

gd:18 - Parse Error: Invalid argument for “connect()” function: argument 3 should be “int” but is “Callable”.

My timer is called "DelayTimer" and it is connected to the script.

extends CharacterBody2D

# Constants
const GRAVITY = 30.0  # Gravity in pixels per second squared
const JUMP_POWER = -2000.0  # Jump power (negative value for upward force)
const SIDE_JUMP_POWER = 2500.0
const DELAY_TIME = 0.2
# Variables
var switchValue: int = 1
var currentGravity = 30.0

var delay_start_time: float = -1.0  # To track when the delay started
var is_delay_active: bool = false  # To check if the delay is active
@onready var delay_timer = $DelayTimer

	
func _ready():
	delay_timer.connect("timeout", self, _on_timer_timeout)
	

func _physics_process(delta):
	# Apply gravity
	velocity.y +=  currentGravity
	
	# Handle jumping input
	if Input.is_action_just_pressed("ui_touch"): # and is_on_floor():
		velocity.y = JUMP_POWER
		currentGravity = 30
		if switchValue == 0:
			switchValue = 1
			velocity.x = SIDE_JUMP_POWER
		else:
			switchValue = 0
			velocity.x = - SIDE_JUMP_POWER
	# Move the character and handle collisions
	move_and_slide()  # No arguments needed for move_and_slide in CharacterBody2D

	# Optionally, check if on floor to reset jump logic or other conditions

	if is_on_floor():
		# Character is on the floor, adjust any necessary logic
		pass
		


func _on_area_2d_body_entered(body):
	if body.is_in_group("WallGrp"):
		velocity.x = 0
		velocity.y = 0
		currentGravity = 0
		is_delay_active = true  # Activate the delay
		delay_timer.start(DELAY_TIME)

func _on_timer_timeout():
	# This function is called when the Timer times out
	velocity.y += currentGravity
	pass # Replace with function body.

For doing it in code i would use:

func _ready():
	delay_timer.timeout.connect( _on_timer_timeout)

But if your timer is in the same scene you can just click on it, then change the inspector tab to node and double click the “timeout” signal.


Then choose the node with this script and it will automatically connect to the function (or create another one, if the names don’t match up)

1 Like

This worked, thank you so much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.