Automatically stablize rotation

Hey everybody!

I’m making a little hoverboard game, and I have everything set up, except that I can’t make it so that the hoverboard rotation stabilizes, whilst still retaing its Y- rotation.

The code so for:

if((Input.GetAxis("Vertical")+1) * (Input.GetAxis("Horizontal") + 1) == 1)
{
//auto stabilise rotation, except for the mainParent.transform.rotation.y

}


//auto stabilise the speed
if(Input.GetButton("HoverboardBoost") == false)
{
rigidbody.AddForce(-rigidbody.velocity * 3);
}

mainParent is the main parent, as this code goes on each of the 4 thrusters which a children of the main hoverboard gameobject.

I’ve got it to stabilize the velocity, but not the roatation.

Thank you for any help!
Nikita

//auto stabilise rotation, except for the mainParent.transform.rotation.y (because this is the right/left movement)

float rotx =  mainParent.transform.eulerAngles.x - transform.eulerAngles.x;
float rotz = mainParent.transform.eulerAngles.z - transform.eulerAngles.z;
Quaternion.Lerp(transform.rotation, Quaternion.Euler(rotx, 0, rotz), 0.99f);