My code seems to be the same, why am I getting this error?

"Invalid call. Nonexistent function ‘setup_camera’ in base ‘Camera2D’. My function is named correctly. Here’s some code, starting with the GameCamera script

extends Camera2D

var player: Player = null

func _ready():
pass

func _process(delta):
pass

func _physics_process(delta):
if player:
global_position.y = player.global_position.y

func setup_camera(_player: Player):
if _player != null:
player = _player

and then here’s my game.gd code:

extends Node2D

var camera_scene = preload(“res://scenes/game_camera.tscn”)

var camera = null

func _ready():
camera = camera_scene.instantiate()
camera.setup_camera($Player)
add_child(camera)

func _process(delta):
pass

I figured it out… somehow managed to never connect the game camera script to the scene

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

Privacy & Terms