Resuming from pause state locks the new textured reticle

Godot Version

Godot 4.2.1

Question

I created a reticle as a replacement for the player’s mouse, however if the player pauses the game and then presses the Resume button then the reticle is locked in place. If you move the mouse in a direction you can see it try to move that direction but immediately snap back on the next available frame. Please let me know if any additional information needs to be provided, I tried taking a video but my OBS kept crashing with Godot. It’s weird, if I alt+tab out of the game while it is running and then I mouse over the game the reticle will move and follow the mouse position.

world.gd:

extends Node2D

@onready var menu = $CanvasLayer/pauseMenu
@onready var heartsContainer = $CanvasLayer/heartsContainer
@onready var player = $TileMap/player

var paused = false

func _ready():
    heartsContainer.setMaxHearts(player.maxHealth)
    heartsContainer.updateHearts(player.currentHealth)
    player.healthChanged.connect(heartsContainer.updateHearts)

func _process(delta):
    if Input.is_action_just_pressed("pause"):
        pause(paused)
        
func pause(state):
    if state:
        Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
        menu.hide()
        get_tree().paused = false

    else:
        Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
        get_tree().paused = true
        menu.show()
        
    paused = !paused

cursor.gd

extends Control

func _ready():
    # Hide the system cursor
    Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)

func _process(delta):
    # Update the cursor position based on the mouse position
    var rect_position = get_global_mouse_position()
    custom_minimum_size = Vector2(1, 1)  # Set a minimum size to avoid scaling issues
    size = custom_minimum_size
    rect_position.x -= size.x * 0.5
    rect_position.y -= size.y * 0.5
    global_position = rect_position

pause_menu.gd

extends Control

@onready var main = $"../../"

var paused = false

func _on_resume_pressed():
    print_debug("Resume pressed")
    main.pause(!paused)

func _on_controls_pressed():
    pass # Replace with function body.

func _on_quit_pressed():
    print_debug("Quit pressed")
    get_tree().quit()

image

I could only include one image in the post, so here is the pauseMenu tree

image

there’s a way by setting it via project settings and even from script if you want to set custom cursor like explained here Customizing the mouse cursor — Godot Engine (stable) documentation in English

Wow! The tutorial I was watching must have been outdated.

Thank you SO much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.