1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-24 17:14:23 +00:00

Add a get_via_group method to Cursor

This commit is contained in:
Steffo 2024-04-20 02:17:40 +02:00
parent 549dc2a1b3
commit 3d9233f01f
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -7,5 +7,12 @@ class_name Cursor
@onready var game := MainGame.get_via_group(self)
static func get_via_group(node: Node) -> MainGame:
var result = node.get_tree().get_nodes_in_group("cursor")
if result.is_empty():
return null
return result[0]
func _physics_process(_delta: float) -> void:
move_and_collide(game.camera.get_global_mouse_position() - global_position)