func _ready() -> void:
- if not last_movement_direction:
- last_movement_direction = Vector3.BACK.rotated(Vector3.UP, rotation.y)
+ if last_movement_direction:
+ last_movement_direction = last_movement_direction.normalized()
+ else:
+ last_movement_direction = Vector3.BACK.rotated(Vector3.UP, global_rotation.y)
+
hurtbox.weapon = weapon
hurtbox.is_attacking = true
hurtbox.set_collision_layer(collision_layer)
hurtbox.set_collision_mask(collision_mask)
_origin = global_position
+
+ # TODO: if projectile gets reflected, this must be recalculated!
+ var target_angle := Vector3.BACK.signed_angle_to(last_movement_direction, Vector3.UP)
+ global_rotate(Vector3.UP, target_angle)
func _process(delta: float) -> void:
else:
global_position = lerp(
global_position,
- global_position + speed * last_movement_direction.normalized(),
+ global_position + speed * last_movement_direction,
delta
)