2025-06-29 21:26:14 +03:00
|
|
|
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:
|
2025-06-29 22:19:02 +03:00
|
|
|
rotation = lerp_angle(rotation, mouse_velocity.angle(), 80 * delta)
|
|
|
|
|
|
2025-06-29 21:26:14 +03:00
|
|
|
|
|
|
|
|
var direction_to_mouse = (current_mouse_pos - global_position).normalized()
|
|
|
|
|
global_position = current_mouse_pos
|
|
|
|
|
|
|
|
|
|
old_mouse_pos = current_mouse_pos
|
|
|
|
|
pass
|