Boat Rotation in 2 axis

I have a boat gameobject which I want to rotate in 2 axis seperately, not a combined vectoral angle.

Y axis rotation > YAW
Z axis rotation > ROLL

when I write:

transform.Rotate(0, Input.GetAxis("Horizontal")*rotSpeed*Time.deltaTime, rotSpeed*Time.deltaTime);

I get a rotation effect that is combination of both axis, not each one seperately. Here is what I also tried:

void Update () {
        //move forward
        transform.Translate(0, 0, Input.GetAxis("Vertical") * 3 * Time.deltaTime);

        transform.Rotate(0, Input.GetAxis("Horizontal") * rotSpeed * Time.deltaTime, 0);

        if (Input.GetAxis("Horizontal") > 0)  //lean right
        {
            //animation.CrossFade("leanRight");  //doesnt work well
            //transform.RotateAroundLocal(Vector3.forward, 20);  //doesnt work at all
            //transform.localEulerAngles = new Vector3(0, 0, 15);  //doesnt work at all

        }
        else if (Input.GetAxis("Horizontal") < 0)  //lean left
        {
            //animation.CrossFade("leanLeft");  //doesnt work well
            //transform.RotateAroundLocal(Vector3.forward, -20);  //doesnt work at all
            //transform.localEulerAngles = new Vector3(0, 0, /15);  //doesnt work at all
        }
}

I’m guessing a little here (since I don’t know exactly what sort of behavior you want), but it sounds like a simple ‘from scratch’ Euler angle construction might be what you’re looking for.

The Unity docs state that Euler rotations are applied in the order z->x->y, which is what you want. So, you would store your z and y rotation angles as floats, update them in response to user input, and then build your orientation like this:

transform.rotation = Quaternion.Euler(0f, yAngle, zAngle);

(Again though, I’m not completely sure if that’s the behavior you’re looking for.)

Hi Jesse, thanks for your reply, I tried your code but didnt work for me…Here is a link to the very same problem someone else is having with flash papervision… Could be more explanatory of my problem…
http://www.flashsaves.com/pv3d_rollerror/turn/

Have you seen this? http://www.unifycommunity.com/wiki/index.php?title=ShipControls Might give you some ideas.

Thanks bigkahuna i’ve checked it and seems to be very useful