summaryrefslogtreecommitdiff
path: root/Units/Unit.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Units/Unit.gd')
-rw-r--r--Units/Unit.gd12
1 files changed, 9 insertions, 3 deletions
diff --git a/Units/Unit.gd b/Units/Unit.gd
index 551e13f..ea64c26 100644
--- a/Units/Unit.gd
+++ b/Units/Unit.gd
@@ -66,7 +66,13 @@ var roaming_mode = false
@onready var sprite: Sprite2D = $Sprite2D
+func _init():
+ scale = Vector2(Client.current_stage.map.tile_set.tile_size) / Vector2(16, 16)
+
+
func _ready():
+ base_speed *= scale.x
+
if not target:
if target_path:
target = get_node(target_path)
@@ -138,7 +144,7 @@ func _physics_process(delta):
func _draw():
if is_selected:
draw_circle(
- Vector2.ZERO,
+ $Sprite2D.position,
Client.current_stage.map.tile_set.tile_size.x * 0.75,
Color(1, 1, 1, 0.75),
false,
@@ -147,7 +153,7 @@ func _draw():
modulate = Color(1.5, 1.5, 1.5)
elif is_hovered:
draw_circle(
- Vector2.ZERO,
+ $Sprite2D.position,
Client.current_stage.map.tile_set.tile_size.x * 0.75,
Color(1, 1, 1, 0.5),
false,
@@ -173,7 +179,7 @@ func _on_navigation_base_area_entered(area: Area2D):
func walk_along_path(path: PackedVector2Array, index: int, delta: float):
immediate_target = path[index]
- var displacement := immediate_target - global_position
+ var displacement: Vector2 = immediate_target - global_position
var direction := displacement.normalized()
var distance := displacement.length()