Rotating a 2d object

In my space shooter game I want to rotate my asteroids two-dimensionally.

I put together this script, but now the asteroid rotates three-dimensionally:

using UnityEngine;
using System.Collections;

public class RandomRotater : MonoBehaviour 
	public float rotate;

	void Start ()
		rigidbody.angularVelocity = Random.insideUnitSphere * rotate;

How can I do it so it simply just rotates a random amount of degrees pr. second?

If the game is 2D, you might want to be using a Rigidbody2D instead of a Rigidbody. The angularVelocity property of a Rigidbody2D is a float in degrees per second - exactly what you need:

rigidbody.angularVelocity = Random.value * rotation;

If you’re set on using a 3D rigidbody, though, you’re going to want to set just a single type of rotation, normally Z:

rigidbody.angularVelocity = new Vector3(0.0F, 0.0F, Random.value * rotation);