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

Fix reference acquisition in MoveTowardsMouse

This commit is contained in:
Steffo 2024-04-14 04:18:38 +02:00
parent 04d6e78228
commit c7bd5c9359
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -8,7 +8,7 @@ signal captured
@export_range(-500, 500, 1) var speed: float = 100.0 @export_range(-500, 500, 1) var speed: float = 100.0
@onready var game := MainGame.get_ancestor(self) @onready var camera := MainGame.get_ancestor(self).camera
enum State { STILL, CAPTURED } enum State { STILL, CAPTURED }
@ -17,7 +17,7 @@ var state: State = State.STILL
func get_relative_mouse_position(): func get_relative_mouse_position():
var global_mouse_position: Vector2 = game.camera.get_global_mouse_position() var global_mouse_position: Vector2 = camera.get_global_mouse_position()
var relative_mouse_position: Vector2 = global_mouse_position - global_position var relative_mouse_position: Vector2 = global_mouse_position - global_position
return relative_mouse_position return relative_mouse_position