Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | EliTheBeeli |
I’m trying to make a main menu that allows the player to choose between either a human or computer opponent. I have an Opponent scene that can have either one of two scripts: Human or Computer. I also have a Main Menu scene with two buttons (Human or Computer), and a Level scene. To communicate between the two scenes I have a Global script that’s AutoLoaded, which has a variable OpponentType that = “Computer” by default.
Buttons:
func _on_HumanButton_pressed():
get_node("/root/GlobalScript").OpponentType = "Human"
get_tree().change_scene("res://Level/Level.tscn")
func _on_ComputerButton_pressed():
get_tree().change_scene("res://Level/Level.tscn")
Level:
func _ready():
if(get_node("/root/GlobalScript").OpponentType == "Human"):
$Opponent.set_script(load("res://Player/Human.gd"))
else:
$Opponent.set_script(load("res://Player/Computer.gd"))
The scripts are loaded to Opponent as intended (checked via Remote while running the game), but Opponent still does nothing. What step of my process is wrong? Happy to answer clarifying questions.