首页 > 解决方案 > Cant unpause in godot

问题描述

I am making a game in godot. But I can't unpause after pausing. I used Input Map to create two keyboard shortcuts(one to pause and other to un-pause) and auto-loaded the script. This is the code:

extends Node


var players_coin = 0

func _ready():
    PAUSE_MODE_PROCESS

func _input(event):

    if Input.is_action_pressed("pause"):
        get_tree().paused = true

    if Input.is_action_pressed("unpause"):
        get_tree().paused = false

I am bad at stack overflow, but this should work.

I am using "Godot 3.2.2.stable" and any help would be great.

标签: godotpause

解决方案


只需您的就绪功能替换为以下内容:

func _ready():
       pause_mode = Node.PAUSE_MODE_PROCESS

或者您可以在 Inspector Tab 下的 Node 中执行相同的操作。

这是官方文档链接


推荐阅读