Hi folks, I tried to replicate word for word and step by step a mini game based on Martian Mike however I’m getting an error when running the game. Error is Invalid get index ‘touched_player’ (on base: ‘AnimationPlayer’).
Code for Level that I’ve got:
@onready var start_position = $StartPosition
@onready var player = $Player
func _ready():
var traps = get_tree().get_nodes_in_group("traps")
for trap in traps:
trap.touched_player.connect(_on_trap_touched_player)
func _process(delta):
if Input.is_action_just_pressed("quit"):
get_tree().quit()
elif Input.is_action_just_pressed("reset"):
get_tree().reload_current_scene()
func _on_deathzone_body_entered(body):
reset_player()
func _on_trap_touched_player():
reset_player()
func reset_player():
player.velocity = Vector2.ZERO
player.global_position = start_position.global_position
Code for trap.gd:
extends Node2D
signal touched_player
func _on_area_2d_body_entered(body):
if body is Player:
touched_player.emit()
Really stumped! Here’s another screenshot in detail when that error message appears when I run the game: