Hey everyone, I’m just getting started in Unity and having a blast.
Right now I’m trying to get some basic aircraft controls working and was wondering if someone could point me in the right direction. Even non-Unity example code would be awesome. I have had success creating a very arcade-like control scheme, but you cannot do rolls or loops. My issue is that my angles start getting all messed up when I enable that type of control.
Here is a snippet… I’m sure there is an easier way and I’m just not seeing it. This is for the iPhone BTW.
Limited controls (works perfectly, but not very aircraft-like
euler.y += accelerator.x * turnSpeed;
euler.z = Mathf.Lerp(euler.z, -accelerator.x * maxTurnLean, 0.2);
euler.x = Mathf.Lerp(euler.x, accelerator.y * maxTilt, 0.2 );
var rot : Quaternion = Quaternion.Euler(euler);
transform.rotation = Quaternion.Lerp(transform.rotation, rot, sensitivity);
My attempt at enabling loops was to make the x-axis rotation additive by changing the line above to this:
euler.x += accelerator.y * turnSpeed;
This works to some extent, but after you do a loop, all the controls are reversed. I tried the same with rolls (z-axis) and it was utter chaos.
Any help is much appreciated.