I made a mistake in thinking that you could get the global angular velocity by just subtracting the current rotation from the previous rotation.
I search further on the internet and found user balintmaci who put this code for getting (global) angular velocity.
https://github.com/godotengine/godot-proposals/issues/3626
Angular velocity is difficult to calculate when throwing rigid bodies in VR games #3626
func calculate_angular_velocity(orientation_new: Basis, orientation_old: Basis, time_new: int, time_old: int):
var time_elapsed = (time_new - time_old) / 1000000.0 # convert microseconds to seconds
var orientation_new_relative_to_old = orientation_old.inverse() * orientation_new
var axis_angle_new_relative_to_old = quat2axis_angle(Quat(orientation_new_relative_to_old))
var angular_velocity_in_relative_frame = axis_angle_new_relative_to_old / time_elapsed
return orientation_old * angular_velocity_in_relative_frame # axis transformed back to global frame, but retains magnitude
static func quat2axis_angle(q: Quat):
var v = Vector3(q.x, q.y, q.z)
var angle = 2 * atan2(v.length(), q.w)
return v.normalized() * angle
I edited it a little in my test project and it worked, yay!
