Godot Version
4.3
Question
I have a script that interpolates the position and rotation rigid bodies between physics frames so that it looks good on higher refresh rates. It works fine for the most part, but occasionally, the rotation will bug out. Like the object will randomly turn 180 degrees and other such issues.
This is the code i use:
func _process(_delta):
var frac = Engine.get_physics_interpolation_fraction()
global_position = lerp(prev_pos, current_pos, frac)
global_rotation.y = lerp_angle(prev_rot.y, current_rot.y, frac)
global_rotation.x = lerp_angle(prev_rot.x, current_rot.x, frac)
global_rotation.z = lerp_angle(prev_rot.z, current_rot.z, frac)
note that the script is attached to the mesh corresponding to the rigid body, not the rigid body itself.