move mouse cursor alongside with the player using gdscript
13:53 22 Dec 2025

Im currently trying to improve my programming by remaking different games using godot. Currently im working on a Hotline Miami clone. My player rotates to the direction of the mouse and can move like in the game (left, right, up, down etc.), my problem is that the mouse cursor isnt moving when the player is moving. Example: the player is moving 300px up on the y axis, but the mouse isnt moving these 300px along side it. Havent found anything on the internet about moving the mouse in realtime through script. Any suggestions?. Here is my current code (new to godot) :

extends CharacterBody2D

var speed = 10

func _ready() -> void:
    pass

func _process(_delta: float) -> void:
    var mouse_pos = get_global_mouse_position()
    
    rotation = (mouse_pos - global_position).angle() + deg_to_rad(90)
    
    if Input.is_action_pressed("forward"):
        position.y -= speed
    if Input.is_action_pressed("back"):
        position.y += speed
    if Input.is_action_pressed("left"):
        position.x -= speed
    if Input.is_action_pressed("right"):
        position.x += speed
godot gdscript