Long time no reply, just wanted to paste my solution real fast for posterity. Thanks to @gertkeno and @pennyloafers for their help.
The Solution
So the scene is still the same with an updated script. It’s a little hard to explain what changed as physics math is confusing. But essentially the issue was due to raycast math and having to use the to_local on the raycast.
Not sure how the raycast math works, but the most important thing is that it works and I can use it for other features.
Code:
func wrench_attack() -> void:
# Wrench damage values
const WRENCH_DAMAGE : int = 25
# Get all Area3Ds upon performing a wrench attack
var Hitboxes:Variant = Wrench_Hitbox.get_overlapping_areas()
# Loop through all area3Ds
for Box:Area3D in Hitboxes:
# Get the Area3D's parent node and parent name (This works)
var Hitbox : Node = Box.get_parent()
var Hitbox_Name : String = Box.get_parent().name
# Loops through the collided hitboxes for-
# - players to hit. (And ignore self)
if Hitbox.has_node("PlayerDamageCollision") \
and Hitbox_Name != Player_ID:
# Get the enemy's LOS reference node and local hitbox position
var Hit_Player_LOS_Position : Vector3 = Hitbox.get_node("GlobalLineOfSightReference").global_position
var Raycast_Target_Location : Vector3 = Global_Line_Of_Sight_Raycast.to_local(Hit_Player_LOS_Position)
# Send the LOS raycast to the enemy's location and force and update
Global_Line_Of_Sight_Raycast.target_position = Raycast_Target_Location
Global_Line_Of_Sight_Raycast.force_raycast_update()
# Checks if the LOS raycast hits a surface (body)
if Global_Line_Of_Sight_Raycast.is_colliding() == false:
# Damages the enemy hit
Hitbox.get_node("PlayerDamageCollision").damage(WRENCH_DAMAGE)
# Continue if the LOS raycast fails
else: continue
# Ignore everything that isn't an enemy player hitbox
else: pass