I have been working on this dang problem trying everything I can find and just cannot seem to get just the right mix of code I guess.
What seems to be the biggest issue is when I tilt the plane left or right so the wings are no longer horizontal and then try to tilt forward or backward it doesn’t really act like it should because using Quaternion.Slerp doesn’t use the Space.Self(is my guess).
If your plane is horizontal then you can tilt forward/backward correctly because it sees the rotation the correct way. I am assuming this is probably just something simple im missing.
Here is my code.
if (Input.GetAxis("Vertical") != 0) {
//Pretty much works
float tiltAroundX = Input.GetAxis("Vertical") * maxRotation + transform.rotation.x;
transform.Rotate(new Vector3(tiltAroundX, 0, 0), 10, Space.Self);
}
float tiltAroundZ = Input.GetAxis("Horizontal") * maxRotation;
Quaternion target = Quaternion.Euler(0, 0, tiltAroundZ);
transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * rotationDamping);
This works for the most part but its not smooth like it would be if I was somehow able to use Slerp.
If you change it up to something like this
float tiltAroundX = Input.GetAxis("Vertical") * maxRotation;
float tiltAroundZ = Input.GetAxis("Horizontal") * maxRotation;
Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ);
transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * rotationDamping);
You can see what I mean by it doesn’t rotate like I would quite expect it.
Anyone have any ideas or pointers?
Thanks!