The Godot Community Forums are back up and running! Please read the the announcement post for important information on what happened. Thanks!

Can I change a variable in change_scene ?

Hi, I'm working on some levels and want to be able to change a variable when the level scene is loaded (so the same level can be played in different modes -as capture the flag or last player alive etc.

From a level selection menu there's a button that changes the scene - script:

func _on_button1_pressed() -> void:
get_tree().change_scene("res://Arena3.tscn") #how do I set the variable 'ctf_on = true' in this scene from here?
_close_menu()

If perhaps there's a better way to do this I'm all ears. (i tried using signals via a singleton, but the variable is needed in the 'ready' for the Arena3-scene, and the signal seems to come in too late).
Thanks!
-W

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file