Hi, when I try to do the body is Player check, it gives me an error saying “Player” is not in scope. I’ve tried using a lower case player and it returns "player is a variable but does not contain a type.
My full code below:
extends Node2D
var player = null
@onready var startPos = $StartScene
@onready var exit = $Exit
func _ready():
player = get_tree().get_first_node_in_group("player")
var traps = get_tree().get_nodes_in_group("Traps")
for trap in traps:
trap.touched_player.connect(_on_trap_touched_player)
exit.body_entered.connect(_on_exit_body_entered)
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 = startPos.get_spawn_pos()
func _on_exit_body_entered(body):
if body is player:
exit.animate()