Rotate on Z axis forward and backward.


I’d like to know how to properly rotate on Z axis.
To be more specific, it should work like this:

Rotate forward (object lean forward) and Z axis is getting bigger from 0.

Rotate backward (object lean backward) and Z axis is getting smaller from 0.

Why I ask? Here is my code that I’m using to rotate.

if(Input.GetKey(KeyCode.W)) {
	transform.Rotate(-Vector3.forward * Time.deltaTime * 20.0f, Space.Self);
else if(Input.GetKey(KeyCode.S)) {
	transform.Rotate(Vector3.forward * Time.deltaTime * 20.0f, Space.Self);

That’s all. But when I’m holding W key, Z axis is starting at 360 and getting lower but holding S key is working properly (almost) but it starts at 0 and getting higher, 1, 2, 3 etc. I’d like to add that in Scene when I’m rotating, Z axis is working properly.

Use this …

Transform.Rotate( 0f, 0f, 3.5f );

where it says "3.5f put in whatever value you want.