ft: drag to move

This commit is contained in:
djaidjai committed 2026-03-15 16:51:01 +01:00
1 parent 6239bbdd73
commit c20985ac91
5 files changed
+10 -20

No files matched your search

@@ -24,7 +24,7 @@ var isAlive: bool = true
@onready var invulnerable_cooldown_timer: Timer = $InvulnerableCooldownTimer
var hasiframes: bool = false # only used for iframe after collision for now
var target = Vector2.ZERO # either vector2 or Node2D
var updating_target: bool = false
var updating_target: bool = false # TODO: overhaul; make own node/script and actually expand logic properly
func _ready() -> void:
var screen_size = get_viewport_rect().size
@@ -38,9 +38,6 @@ func _ready() -> void:
func _input(event):
# TODO: only does clicks/taps; accept mouse drags
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
target = get_global_mouse_position()
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
# start tracking
@@ -50,9 +47,6 @@ func _input(event):
# stop tracking
updating_target = false
if updating_target and event is InputEventMouseMotion:
target = get_global_mouse_position()
func _physics_process(delta):
var pos
if typeof(target) == TYPE_VECTOR2:
@@ -78,6 +72,9 @@ func _process(delta):
if self.rotation != self.desired_rotation:
self.rotation = lerp_angle(self.rotation, self.desired_rotation, clampf(4 * delta, 0, 1))
if typeof(target) == TYPE_VECTOR2 and updating_target:
target = get_global_mouse_position()
func try_attack() -> void:
if not can_attack:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.