0 votes

ok so I have a main menu and a pause menu but the problem is I can pause in the main menu. How do I fix this?

(pause menu code)

extends Control

func process(delta):
if Input.is
actionpressed("ESC"):
visible = true
get
tree().paused = true

func onContinuepressed():
hide()
get
tree().paused = false

func onMainmenupressed():
visible = false
gettree().paused = false
get
tree().change_scene("res://Menu.tscn")

func onquitpressed():
get
tree().paused = false
get_tree().quit()

Godot version 3.4
in Engine by (12 points)

2 Answers

0 votes

Is your pause menu set as autoload? The easiest thing would be to not autoload it and just add an instance of the pause scene to any scenes you do want it to operate in.

If you really want it to autoload you could have a boolean in your pause menu which is set on _ready function of each scene loaded to true or false depending on if the pause should operate there or not then change the pause menu code like

func process(delta):
if NewBoolean and Input.isactionpressed("ESC"):
visible = true
gettree().paused = true
by (1,635 points)
0 votes

You can make your escape key function as a pause and unpause:

func _process(delta):
    if not Input.is_action_just_pressed("ESC"):
        return # do nothing if escape isn't pressed
    elif visible: # we are paused
        visible = false
        get_tree().paused = false 
    else: # we are unpaused
        visible = true
        get_tree().paused = true
by (3,707 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.