bevy_flycam
bevy_flycam copied to clipboard
Use yaw/pitch from Camera's rotation.
Fixes issue with first mouse movement resetting the camera rotation. Query the yaw and pitch from the camera before updating the rotation.
This helps with issue #17.
Nice. I noticed this too. Very annoying as it just happens that first time every time you move the mouse.
I found that another way it could be fixed is copying the same code that the keys use:
let yaw = Quat::from_rotation_y(-(settings.sensitivity * ev.delta.x * window_scale).to_radians());
let pitch = Quat::from_rotation_x(-(settings.sensitivity * ev.delta.y * window_scale).to_radians());
transform.rotation = yaw * transform.rotation; // rotate around global y axis
transform.rotation = transform.rotation * pitch; // rotate around local x axis
(actually on closer inspection this looks pretty much the same as what you've done.)
On the hole I think I prefer that as I think it's a bit sketchy setting the rotation explicitly in one and doing relative transforms in the other ( the original mouse code does not use transform.rotation where as the key side does.... we should do one or the other)