Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | CharlieChicken |
So for my first game in godot I’ve been making a platformer. I have an area2d with a death script collisionshape2d as a child. The code for the script is
(sorry I can’t make the sample code feature work)
extends Area2D
var deaths = 0
func _on_body_entered(_body :PhysicsBody2D):
deaths = deaths + 1
print(deaths)
get_tree().change_scene_to_file(“res://lv_1.tscn”)
This resets the player as I want, but what’s printed in the console is always 1, no matter how many times the player dies. What am I doing wrong?
Now I’m no professional, but try making the script a singleton (Project>Project Settings>AutoLoad)
iNeedMentalHelp | 2023-07-09 08:50