Added Cursor Node

Digital cursor, follows & hides mouse

Hide Mouse can be disabled by ShowMouse = true
This commit is contained in:
2025-06-29 21:26:14 +03:00
parent b477c09351
commit bdde71f829
5 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
extends Node2D
@onready var Cursor = $Cursor
@export var ShowMouse = false
var old_mouse_pos = Vector2.ZERO
var mouse_velocity = Vector2.ZERO
#var speed = 5000.0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
if not ShowMouse : Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
old_mouse_pos = get_viewport().get_mouse_position()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var current_mouse_pos = get_viewport().get_mouse_position()
mouse_velocity = current_mouse_pos - old_mouse_pos
if mouse_velocity.length_squared()>0.1:
rotation = mouse_velocity.angle()
var direction_to_mouse = (current_mouse_pos - global_position).normalized()
global_position = current_mouse_pos
old_mouse_pos = current_mouse_pos
pass