From 30fdfb5a4e80ab24f39737b88bf8daec3602fe7d Mon Sep 17 00:00:00 2001 From: Pawel Lampe Date: Thu, 25 Jan 2024 22:57:17 +0100 Subject: [PATCH] Improve 'MovingToUnit' to account for navigation holes, closes #74 --- source/FeatureFlags.tscn | 1 - source/match/units/actions/MovingToUnit.gd | 8 +++++++- source/match/units/non-player/ResourceUnit.gd | 17 ++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/FeatureFlags.tscn b/source/FeatureFlags.tscn index 222625d..aabe467 100644 --- a/source/FeatureFlags.tscn +++ b/source/FeatureFlags.tscn @@ -4,5 +4,4 @@ [node name="FeatureFlags" type="Node"] script = ExtResource("1_wihie") -allow_navigation_rebaking = false god_mode = true diff --git a/source/match/units/actions/MovingToUnit.gd b/source/match/units/actions/MovingToUnit.gd index 7cd0511..2b57ea0 100644 --- a/source/match/units/actions/MovingToUnit.gd +++ b/source/match/units/actions/MovingToUnit.gd @@ -14,7 +14,13 @@ func _process(_delta): func _ready(): _target_unit.tree_exited.connect(queue_free) - _target_position = _target_unit.global_position + _target_position = ( + _target_unit.global_position_yless + + ( + (_unit.global_position_yless - _target_unit.global_position_yless).normalized() + * _target_unit.radius + ) + ) super() diff --git a/source/match/units/non-player/ResourceUnit.gd b/source/match/units/non-player/ResourceUnit.gd index 76d3049..62daa6c 100644 --- a/source/match/units/non-player/ResourceUnit.gd +++ b/source/match/units/non-player/ResourceUnit.gd @@ -2,23 +2,18 @@ extends Area3D const ResourceDecayAnimation = preload("res://source/match/utils/ResourceDecayAnimation.tscn") -var radius = null: - set = _ignore, - get = _get_radius +var radius: + get: + return find_child("MovementObstacle").radius +var global_position_yless: + get: + return global_position * Vector3(1, 0, 1) func _enter_tree(): tree_exiting.connect(_animate_decay) -func _ignore(_value): - pass - - -func _get_radius(): - return find_child("MovementObstacle").radius - - func _animate_decay(): var decay_animation = ResourceDecayAnimation.instantiate() decay_animation.global_transform = global_transform