Reset rotation of cylinder

Hello everyone. I’m making an air hockey game for my first project because I thought it would be fairly easy. The problem I’m having this far is that when the paddle (cylinder) hit the puck (cylinder) the puck goes vertical and spins. I thought that I could keep the puck laying flat by resetting the rotation to 0 via the puck script’s update function:

function Update () {
	if(transform.rotation.y > 0){
		transform.rotation.y = 0;
	}
	else if(transform.rotation.x > 0){
		transform.rotation.x = 0;
	}
	else{
		transform.rotation.z = 0;
	}
}

This of course did nothing. What am I not doing right?

Also how can I reduce the friction so the puck slides more realistically?

OK I think I got it.

I could not figure out what you meant. So, it was that when hitting the puck, it would start spinning randomly instead of sticking flat to the ground.

In the rigidbody component of your puck, you have contraints, open it and tick freeze rotation for X and Z. Keeping Y unticked will allow your puck to spin while sliding like a real one.

Hope that helps.