Thank you very much, finally thanks to the code you provided me I got it to work. :)
here is the code:
var rot_x = 0
var rot_y = 0
const LOOKAROUND_SPEED = .01
#
func _input(event):
if event is InputEventMouseMotion and event.button_mask & 1:
# modify accumulated mouse rotation
rot_x = event.relative.x * LOOKAROUND_SPEED
rot_y = event.relative.y * LOOKAROUND_SPEED
root_group.rotate(camera.transform.basis.y, rot_x) # first rotate in Y
root_group.rotate(camera.transform.basis.x, rot_y) # then rotate in X
root_group.transform = root_group.transform.orthonormalized()
#if you scale your object you have to put the scale back
#after orthonormalized() like this:
#root_group.transform = root_group.transform.scaled(scale)
just added this
root_group.transform = root_group.transform.orthonormalized()
you have to add it if you rotate bit by bit or the transform will be corrupted over time
as the float data type, like every data type, has a limited accuracy. If you do it like this:
rot_x += event.relative.x * LOOKAROUND_SPEED
rot_y += event.relative.y * LOOKAROUND_SPEED
root_group.transform.basis = Basis() # reset rotation
root_group.rotate(camera.transform.basis.y, rot_x) # first rotate in Y
root_group.rotate(camera.transform.basis.x, rot_y) # then rotate in X
you don't have to do .orthonormalized() but for some reason, the rotation is not
working properly this way.
Thank you again, you saved me so much working time, I appreciate it.