This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
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 (3,328 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,906 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 Frequently asked questions and 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 [email protected] with your username.