So, i have this function where if the player interacts with a area2d, it’ll get a random enemy string and change then change the scene to the battle scene.
What i would like to do is, send the random enemy string generated to the new battle scene without using Singletons/Globals/Auto Loads since i don’t think its necessary
(Sorry for the bad code in advance)
Here’s a look at my code right now:
Since it’s a battle scene I’m assuming it’s a very temporary scene before you’re right back to the normal scene, and recommend not using change_scene. Add the battle scene to the root node, and set the current scene’s process mode to “Disabled”, this will essentially pause everything from before. If need be, hide the current scene too.
func _on_timer_timeout():
var battle := preload("res://scenes/battle.tscn").instantiate()
var tree := get_tree()
tree.current_scene.process_mode = Node.PROCESS_MODE_DISABLED
tree.current_scene.visible = false # if node2/3d
battle.set_enemy(get_random_digimon())
tree.root.add_child(battle)
await battle.finished
battle.queue_free()
tree.current_scene.process_mode = Node.PROCESS_MODE_PAUSABLE
tree.current_scene.visible = true
Thanks, i tried it out and it worked, i’ll try to manage a way to make it usable as in the statement, since i don’t know if i’ll use it in another feature, just to make sure.
The only problem is that the code is running in a singleton