limiting rotation of an object.

So I have a submarine object and I want it to implement two functions dive and surface. But I have to limit the rotation to a maximum value of 30 degrees. I have tried a lot but cannot limit the rotation somehow. The submarine can turn on the y axis. So how I can best approach the problem.

Use Clamp method in the Mathf class. This will allow you to set a min and max and constrain the value of your rotation.