Skip to content

Commit

Permalink
Improve 'MovingToUnit' to account for navigation holes, closes #74
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Jan 25, 2024
1 parent e376d0b commit 30fdfb5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion source/FeatureFlags.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

[node name="FeatureFlags" type="Node"]
script = ExtResource("1_wihie")
allow_navigation_rebaking = false
god_mode = true
8 changes: 7 additions & 1 deletion source/match/units/actions/MovingToUnit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
17 changes: 6 additions & 11 deletions source/match/units/non-player/ResourceUnit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 30fdfb5

Please sign in to comment.