When we lose in a game, it will change the scene from the playing scene to the "Game Over" scene. After a few seconds it will switch the scene to the Game Menu screen.But when I click "Start Game" it switches back to the scene I was playing before I lost and everything remains the same as when I lost. Everything is not RESET. So in that case how should I code so that when it switches, everything is reset. replay scene it must be RESET? Please HELP me! Thank you!
Change scenes
It might help if you post your code showing what you doing.
Very simple a line : Over_scene = get_tree().change_scene("res://Scenes/GameOver.tscn") -----when lose game. Then: wait 5 seconds: new_scene = get_tree().change_scene("res://Scenes/In_game.tscn")----At this point, when entering the game, everything is still not RESET.
That's strange it should be reset as far as I know.
Are you using Singletons (Autoloads)? Because those are not reset.
Actually I don't know what RESET is? Because when returning to the old scene, the features or signal connections seem to be inactive. Only when the game is closed and reopened, it will be normal. If so, how do I change scenes and RESET but the aforementioned features still work the same as when I first opened the game?
Try calling the function without assigning any variable.
Instead of doing this:
new_scene = get_tree().change_scene("res://Scenes/In_game.tscn")
Do this:
get_tree().change_scene("res://Scenes/In_game.tscn")
I also used that way before, but it gives an error even though it still works. If I add 1 variable, it will be ok. As for the scene transition, the problem is still unresolved. Do you have any other way?
Ahihi....I found the error already. Because I set a variable "var losegame = true" when losing the game. And since it's global_script it doesn't RESET like Cyber said. So now just need to add a line of code when losing the game and the GAMEOVER scene transition is complete, just make it false and it's OK. Suddenly I thought and realized it. It's really not a big bug, but it's really hard to find. I would like to thank everyone for their enthusiastic support.