Files
gaim/crosshair.gd
T

22 lines
711 B
GDScript

extends Control
@onready var bob: CharacterBody3D = $".."
@onready var horizontal_line: Line2D = $Horizontal
@onready var vertical_line: Line2D = $Vertical
func _ready():
# Optional: Setze die Länge der Linien
horizontal_line.points = [Vector2(-15, 0), Vector2(15, 0)]
vertical_line.points = [Vector2(0, -15), Vector2(0, 15)]
self.visible = false
# Stelle sicher, dass das Control die Maus sehen kann
mouse_filter = Control.MOUSE_FILTER_IGNORE # sonst blockiert es Input
func _process(delta):
# Setzt die Position des Crosshair-Control auf den Mauszeiger
if bob.mode == bob.PlayerMode.AIM:
self.visible = true
global_position = get_viewport().get_mouse_position()
else:
self.visible = false