Having trouble connecting autoload scenes to anything

Godot Version

4.5

Question

This is the code in one script:
extends Area2D

func _on_body_entered(body: Node2D) → void:
CheckpointManager.checkpoint_reached()

And this is the code inside my autoloaded script named “CheckpointManager”:
extends Node

func checkpoint_reached(position: Vector2):
printerr(“CHECKPOINT”)

Whenever the code is triggered I just get an error that says “Invalid call. Nonexistent function ‘checkpoint_reached’ in base ‘Area2D (checkpoint.gd)’.”

Iv’e also tried this:
extends Area2D

func _on_body_entered(body: Node2D) → void:
get_node(“/root/CheckpointManager”).checkpoint_reached()

Iv’e already tried doing this entire thing with signals, but the connect() function was getting an error despite everything i could find showing that i was dong it right

There’s an argument mismatch: Your checkpoint_reached() function is written to receive an argument (position: Vector2), but you don’t provide that when calling it.

1 Like

I just tried that and it I’m still getting the same error

What does print(CheckpointManager) print? Also post the remote scene tree and autoload script.

Oh, yeah, “in base ‘Area2D (checkpoint.gd)‘” seems as you try to call that function on a checkpoint itself. Maybe you set the wrong scene as autoload?

I just figured it out, i had my two scripts named similarly and had the wrong one set as autoload

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