- Home /
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
}
}
Thanks.
Comment
I posted a reply to your forum thread on the same topic.
And he has asked it on the answers site since then.