what the first 4 lines do is to get the position of the mouse and rotates the object only on the Y AXIS (vector3.up) to the position of the mouse…
on the last line I’ve added the quaternion.euler of the X and Z which I calculated separately…and left Y at 0 so the rotation of that will be by mouse… here’s annoying part:
After I’ve added the first 4 lines and changed the Drone.RB Y rotation’s to 0, then hitting Play the object rotates with mouse but now the X Quaternion is rotated -90 for some reason, and nose of the object is looking up instead of forward… i’m asking if there’s a better way to write this? Really appreciate any advice!
Yes, it’s generally best not to mess with the individual euler angles like this (except when you’re only using one — but you’re using all three).
Instead you should compose rotations by multiplying them together. R2 * R1, where these are quaternions, gives you a rotation by R1 followed by a rotation by R2.
So, I don’t entirely understand what you’re trying to achieve, but I’m pretty sure the right solution is to create a one-axis rotation for each of your three inputs (yaw by mouse; pitch and roll by whatever determines those tilts), and then just multiply them together in the correct order.
Something like this perhaps? on the smoothdamp unless I put 0f it will create this weird affect when rotating fast where the object changes forward position to back position
No, nothing like that. I was suggesting you set up three separate one-axis rotations, and multiply them together. You’re doing a single 3-axis rotation all at once.
However, if you like the order in which Quaternion.Euler does it, then that’s fine.
The problem may be that you’re using Mathf.SmoothDamp with angles. That function doesn’t understand that the numbers you give it represent angles, and so it won’t (for example) interpolate smoothly from 359 to 0 as a 1-degree change; it’ll go the long way, from 359 through 358, 357, etc., all the way down to 0. To work with angles properly, you should use Mathf.SmoothDampAngle instead.