From 15a1d2a66e48324e1d560dc13b776627820f3999 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 27 Oct 2024 15:52:48 +0100 Subject: next commit --- Units/Unit.gd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Units/Unit.gd') 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() -- cgit v1.2.3