Aligning with ground, interpolation breaks

Godot Version

4.7

Question

I was trying to follow the tutorial at KinematicBody: align with surface :: Godot 3 Recipes in order to make my character align with the floor. Granted, I’m using a newer version of Godot and a RigidBody3D instead of a KinematicBody3D/CharacterBody3D for the sake of having proper gravity and momentum, but everything was going well up until the “interpolation to make the rotation smoother” part. After doing that, my player just disappears and I get the error:
E 0:00:00:931 _try_build_shape: Failed to correctly scale body ‘RigidBody3D:<RigidBody3D#30198990369>’. A scale of (260641.000000, 260640.968750, 260640.968750) is not supported by Jolt Physics for this shape/body. The scale will instead be treated as (260640.984375, 260640.984375, 260640.984375).
<C++ Source> modules/jolt_physics/objects/jolt_shaped_object_3d.cpp:71 @ _try_build_shape()
I’ve also tried lerp instead of interpolate_with, but the same thing happens. Again, before this part, the rotation was happening perfectly well other than being sudden snapping. Here’s my full code (yes, there’s an unused variable at the top, I was planning to use it after I got the rotation set up):

extends RigidBody3D

@export var _thrust = 50
@export var _stick_force = 10
@export var _jump_force = 5
@export var _rotate_speed = 20
@export var _skid_force = 10
@export var _decel_force = 5
var _input
var _direction
var _current_thrust
var _velocity
var _is_grounded
var _ground_normal = Vector3.UP
var _last_horiz_rot = 0.0
@onready var _player_model = $AwakeningAtlas
@onready var _ground_ray = $AwakeningAtlas/RayCast3D
@onready var _camera = $“../Camera3D”

# Called when the node enters the scene tree for the first time.

func _ready() → void:
pass # Replace with function body.

# Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _physics_process(delta: float) → void:

# Find ground
_is_grounded = _ground_ray.is_colliding()
if _is_grounded:
	_ground_normal = _ground_ray.get_collision_normal()
else:
	_ground_normal = Vector3.UP

# Find slope angle
var _slope_angle = _ground_normal.signed_angle_to(Vector3.UP, Vector3.UP)
var _slope_deg = abs(rad_to_deg(_slope_angle))

# Set up for various velocity checks
var _flat_linear_velocity = Vector3(linear_velocity.x, 0, linear_velocity.z)
_velocity = linear_velocity.length()

# Turn off gravity if grounded and slope not too steep
if _is_grounded and _slope_deg <= 45:
	gravity_scale = 0
elif _is_grounded and _slope_deg > 45:
	if _velocity < 0.5 and _slope_deg >= 170:
		gravity_scale = 1
		#apply_impulse(_ground_normal * _jump_force)
		print("unstick")
	else:
		gravity_scale = 1
		# Sticking force
		apply_central_force(-_ground_normal * _stick_force)
else:
	gravity_scale = 2

# Get input and direction
#if (_is_grounded and _slope_deg <= 90) or not _is_grounded:
_input = Input.get_vector("MoveLeft", "MoveRight",
		"MoveForward", "MoveBackward")
#elif _is_grounded and _slope_deg > 90:
	#_input = Input.get_vector("MoveRight", "MoveLeft",
			#"MoveForward", "MoveBackward")
_direction = (_camera.basis * Vector3(_input.x,
		0, _input.y)).normalized()

# Rotate controls with slope
_direction = _direction.slide(_ground_normal)
if _direction:
	# Find input near backwards to movement direction
	var _should_skid = false
	if _velocity > 0.5:
		var _angle = _direction.signed_angle_to(_flat_linear_velocity.normalized(), Vector3.UP)
		if abs(rad_to_deg(_angle)) > 95:
			_should_skid = true
	
	# Skid decelerate
	if _should_skid:
		apply_central_force(-_flat_linear_velocity.normalized() * _skid_force)
	elif _is_grounded and _slope_deg <= 90:
		apply_central_force(_direction * _thrust)
elif _flat_linear_velocity != Vector3.ZERO:
	apply_central_force(-_flat_linear_velocity.normalized() * _decel_force)

# Rotate player model horizontally
if _flat_linear_velocity.length() > 0.5:
	var _horiz_rot = 0
	if _is_grounded and _slope_deg > 90:
		_horiz_rot = atan2(_flat_linear_velocity.x, _flat_linear_velocity.z)
	else:
		_horiz_rot = atan2(-_flat_linear_velocity.x, _flat_linear_velocity.z)
	_player_model.rotation.y = _horiz_rot
	_last_horiz_rot = _horiz_rot
else:
	_player_model.rotation.y = _last_horiz_rot

# Rotate player vertically
var xform = align_with_y(global_transform, Vector3.UP)
if _is_grounded:
	xform = align_with_y(global_transform, _ground_normal)
	global_transform = global_transform.interpolate_with(xform, _rotate_speed)
else:
	xform = align_with_y(global_transform, Vector3.UP)
	global_transform = global_transform.interpolate_with(xform, _rotate_speed)

# Jump
if Input.is_action_pressed("Jump") and _is_grounded:
	apply_impulse(_ground_normal * _jump_force)
	_is_grounded = false

func align_with_y(xform, new_y):
xform.basis.y = new_y
xform.basis.x = xform.basis.z.cross(new_y)
xform.basis = xform.basis.orthonormalized()
return xform