Improve aim assist target stickiness

This commit is contained in:
Loïc Wisniewski 2026-09-02 17:15:12 +02:00
commit 3975959017
5 changed files with 122 additions and 64 deletions

View file

@ -104,9 +104,16 @@ func aim(direction: Vector2) -> void:
func aim_at(point: Vector2) -> void:
if fleet == null:
return
aim_point = point
var origin: Vector2 = fleet.get_centroid()
var reach: float = guide_range()
# The reticle resolves once from the fleet centre, so the player's cursor
# visibly sticks. Hulls keep the raw point and resolve it from their own
# muzzle/range below; a short-range ship must not bend toward something it
# cannot actually reach (#172).
aim_point = WEAPON_COMPONENT.assisted_point(get_tree(), origin, point, reach) \
if reach > 0.0 else point
has_aim = true
aim_direction = point - fleet.get_centroid()
aim_direction = aim_point - origin
for ship in fleet.ships:
if not is_instance_valid(ship):
continue
@ -148,10 +155,9 @@ func _draw() -> void:
if reach <= 0.0:
return
var origin: Vector2 = fleet.get_centroid()
# Drawn along the heading a shot will ACTUALLY take, assist included, so
# the line keeps telling the truth about where fire is going (#89).
var heading: Vector2 = WEAPON_COMPONENT.assisted_heading(get_tree(), origin,
aim_direction, reach)
# aim_at() has already resolved the shared assisted point, so the line and
# reticle show the position that every in-range hull resolves toward (#181).
var heading: Vector2 = aim_direction.normalized()
# #172: the line stops at the aimed PLACE when that is inside the guns'
# reach. Running it on to full range past a point the fleet is converging
# on would be drawing a direction again, which is what the ticket took