So, I want to have an inventory that pauses the game whenever it's open, so kinda like Silent Hill. The issue with this is that the time stop is irregular: when the inventory is not open, if you press the inventory key (TAB), the time will stop immediately, and then various animations will play. But when the inventory is open, if you press the inventory key again, the inventory should close, but the time should return to normal after 0.5 seconds. I tried using a boolean to control the time stop, but it didn't work.
If it was just a screen that appeared instantly when pressing TAB, I would just do something like:
if input.is_action_just_pressed(“Inventory”):
get_tree().paused = not get_tree().paused
But since it has all the delays and animations in between, I can't figure out how to toggle the inventory.
These are the functions I want to execute when pressing the inventory key
func InventoryOn():
get_tree().paused = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
FadeAnim.play("FadeOut")
yield(get_tree().create_timer(0.5), "timeout")
#PLay inventory fade in
yield(get_tree().create_timer(0.5), "timeout")
InventoryActive = true
func InventoryOff():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
#Play inventory fade out
yield(get_tree().create_timer(0.5), "timeout")
FadeAnim.play("FadeIn")
InventoryActive = false
get_tree().paused = false