#Main menu doesn't work after i go to it from pause menu

1 messages · Page 1 of 1 (latest)

stable oar
#

When i open my game, my main menu works normally, but when I go to my pause menu and then use it to go to my main menu, the buttons stop working.

#
extends Control

func _process(_delta):
    testEsc()

func resume():
    get_tree().paused = false
    hide()
    Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func pause():
    
    get_tree().paused = true
    show()
    Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)


func testEsc():
    if Input.is_action_just_pressed("esc") and get_tree().paused == false:
        pause()
    elif Input.is_action_just_pressed("esc") and get_tree().paused == true:
        resume()


func _on_resume_pressed():
    resume()


func _on_go_to_menu_pressed():
    get_tree().change_scene_to_file("res://Main menu.tscn")
#

am i doing something silly that's messing with it, i don't get it

lofty aspen
#

When you call _on_go_to_menu_pressed(), try also adding get_tree().paused = false

If that doesn't resolve anything, I would ask that you share the scene tree and the main menu code as well

mortal field
#

I feel it's also the same issue, try doing get_tree().paused = false since it's only switching scenes, and not unpausing

stable oar
#

okay i tried doing that but pressing main menu on the pause just breaks it now

stable oar
#

is my system just bad for what im trying to do

lofty aspen
#

I don't think it is bad.

Do this for me:
in _ready() in your main_menu.gd, put this:

print("Paused: ", get_tree().paused)

stable oar
#

in my... _ready?

#

or do you want me to add it to my main_gd

lofty aspen
#

Add it to your main_menu

#

Just for testing

stable oar
#

like this?

#

it still breaks

lofty aspen
#

Sorry, also remove the get_tree().paused = false in your _on_go_to_menu_pressed() function

#

Or comment it out at least

stable oar
#

okay i removed it, it works again but the main menu continues to be broken :(

lofty aspen
#

Hrm, does it print anything to the console when main menu loads up now?

stable oar
#

this is printed :O

lofty aspen
#

Interesting.

In main_menu.gd, in your _ready() function, remove the print and just put get_tree().paused = false

Then whenever you load the scene, if it's paused for whatever reason it should unpause

stable oar
#

oh my god it works!!!!!!!!!

#

that fixed it !!!! :D

lofty aspen
#

Let's goooo

stable oar
#

thank u very much o7