mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-26 01:54:23 +00:00
Fix MoveTowardsMouse
using the wrong coordinate system
This commit is contained in:
parent
4b24dd1fc3
commit
2849dee2dc
1 changed files with 2 additions and 5 deletions
|
@ -8,8 +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 viewport: Viewport = get_viewport()
|
@onready var game := MainGame.get_ancestor(self)
|
||||||
@onready var camera: GameCamera = GameCamera.get_ancestor(self)
|
|
||||||
|
|
||||||
|
|
||||||
enum State { STILL, CAPTURED }
|
enum State { STILL, CAPTURED }
|
||||||
|
@ -18,9 +17,7 @@ var state: State = State.STILL
|
||||||
|
|
||||||
|
|
||||||
func get_relative_mouse_position():
|
func get_relative_mouse_position():
|
||||||
var camera: Camera
|
var global_mouse_position: Vector2 = game.camera.get_global_mouse_position()
|
||||||
var viewport_mouse_position: Vector2 = viewport.get_mouse_position()
|
|
||||||
var global_mouse_position: Vector2 = viewport_position + viewport_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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue