Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | rousbound |
I have this function:
func _on_PlayAgain_pressed():
print("PLAYERS:", Global.Player1, " ", Global.Player2)
get_tree().reload_current_scene()
pass
The print outputs the player objects, and then on the same reloaded scene script I have:
var Player1 = Global.Player1
var Player2 = Global.Player2
Which prints null for both.
I don’t have any other function inbetween these two pieces of code.
I tried to change scene instead of reloading and the outcome is the same.
My global script has the following piece of code:
var Player1 : KinematicBody2D = null
var Player2 : KinematicBody2D = null
Maybe it is reloading the global script? Is this the expected behavior? I thought that global values should last between scenes.