# Random rotation of instantiated prefab along one axis

I'm trying to rotate a instantiated prefab along just the x axis at random, i've tried the Random.rotate but of course it rotates along all on the axis. I understand that i have to use Quaternion.eulerAngles but I'm still confused.

``````var grass : GameObject;

function Start() {
var grassNum = Random.Range(200, 300);
for (var i = 0; i < grassNum; i++){
var position = Vector3(Random.Range(2, 6), 1.5, Random.Range(2, 6));
Instantiate(grass, position, Quaternion.identity);
}
}

``````

Thanks - C

If you don't need an object reference, then you can instantiate the object after you create a rotation.:

``````var grass : GameObject;

function Start() {
var grassNum = Random.Range(200, 300);
for (var i = 0; i < grassNum; i++){

var randomPosition = Vector3(Random.Range(2, 6), 1.5, Random.Range(2, 6));
var randomRotation = Quaternion.Euler( Random.Range(0, 360) , 0 , 0);

Instantiate(grass, randomPosition, randomRotation);

}
}

``````

And are you sure that you want to rotate around the x-axis? I would guess you want the y-axis which passes vertically through the object so you could spin it like a top and the bottom would stay flat.

``````var grass : GameObject;