godot 4.4.1
I try to make a score mechanic in my game and I have 2 codes for it:
extends Node
var score = 0
@onready var ScoreLabel: Label = $GameManager/ScoreLabel
func add_point():
score += 1
ScoreLabel.text = “You collected " + str(score) + " coins.”
and:
extends Area2D
@onready var game_manager: Node = %GameManager
func _on_body_entered(_body: Node2D) → void:
game_manager.add_point()
queue_free()
IDK why, but the add_point function isn’t visible for the other function.
when I touch a coin the game freezes and I have to try again.
when I touch a coin this error pops out:
Invalid call. Nonexistent function ‘add_point’ in base ‘Node’