#pragma strict

//setup the rotation in all three axis. The Object will rotate only if the speed is more than zero
public var rotationalSpeed : Vector3 = Vector3.zero;
//click this in the inspector or use one of the start/stop functions
public var doRotate : boolean = false;

public function Update() : void
{
	if(doRotate)
	{
		if(rotationalSpeed.x > 0)
		{
			transform.Rotate(Vector3.right,Time.deltaTime * rotationalSpeed.x);
		}
	
		if(rotationalSpeed.y > 0)
		{
			transform.Rotate(Vector3.up,Time.deltaTime * rotationalSpeed.y);
		}
	
		if(rotationalSpeed.z > 0)
		{
			transform.Rotate(Vector3.forward,Time.deltaTime * rotationalSpeed.y);
		}
	}
}

//I made this functions so you can start and stop the rotation from other script
//to do it you can use the following line: transform.Find("myRotatingObject").SendMessage("StartRotation",SendMessageOptions.DontRequireReceiver)
public function StartRotation() : void
{
	doRotate = true;
}

public function StopRotation() : void
{
	doRotate = false;
}