Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Juan Diablos |
I want to load an instance of my inventory scene with the press of “i” and then close it again with the press of “i”. At the minute my inventory scene is loading and is visible but when I press i again i think it closes and then opens again instantly.
Here is the script:
Player script:
func _unhandled_key_input(event):
if Input.is_action_just_pressed(“open_inventory”):
var inventory = load(“res://Scenes//Inventory.tscn”).instance()
add_child(inventory)
print(“i”)
get_tree().paused = true
Inventory script:
func _unhandled_key_input(event):
if Input.is_action_just_pressed(“open_inventory”):
queue_free()
get_tree().paused = false
when I press “i” when the inventory is up it prints “i”
Cheers for the help.