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

Create Cursor matching mouse position on every physics timestep

This commit is contained in:
Steffo 2024-04-16 01:44:06 +02:00
parent fa502ba267
commit 446083dd73
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 17 additions and 0 deletions

11
scenes/game/cursor.gd Normal file
View file

@ -0,0 +1,11 @@
extends Node2D
class_name Cursor
## A [Node2D] syncing its position with the mouse on each physics timestep.
@onready var game := MainGame.get_ancestor(self)
func _physics_process(_delta: float) -> void:
global_position = game.camera.get_global_mouse_position()

6
scenes/game/cursor.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://col1q3elvkfwk"]
[ext_resource type="Script" path="res://scenes/game/cursor.gd" id="1_1og6v"]
[node name="Cursor" type="Node2D"]
script = ExtResource("1_1og6v")