# Rotating specific prefab - instantiated with Random.Range

I have instantiated my Prefabs using Random.Range.(different types of prefabs)
Out of the different instantiated prefabs i want to rotate a specific prefab.

Any help would be appreciated…Thank you

Not coding atm but assuming a small range(0 - 2)

Edit: replacing with actual code and a better explanation. So reading your response @Sanjay1987 i think you are just Rotating on wrong angle, try Y for horizontal, X will make like a ramp and Z is a barrel role idk. But for the code (keep in mind i dont know your code setup/structure so this might not work for you) I also might have misunderstood your question in case you want to do operations after spawn see the comments in the code.

``````	void Start ()
{
for (int i = 0; i < Prefabs.Length; i++)
{
var result = Random.Range(0,2); // This is ouer prefab value
// Alt ver if you want to spawn first Then do change
// var go = insta(pref[res])

// we determin ouer Prefab(in this case i want the prefab at index 1 to be tilted)
if (result == 1 )
{
// angle the prefab on index 1
Instantiate(Prefabs[result], transform.position, Quaternion.Euler(new Vector3(0, 45, 0)));
//go.trans.rot = Quaternion.Euler(new Vector3(0, 45, 0))
}
else
{
Instantiate(Prefabs[result], transform.position, Quaternion.identity);
// go.trans.rot =  Quaternion.identity
}
}
}
``````

The assumption here is that you are using Random value in a Array to determine which prefab to spawn. If we now save that number and say if this value shows up then do something els with the Gameobject(like rotating it) else just do a standard spawn. This is a very basic answer if you need more complex one i think we need to see your script(s).

@RustyCrow Thank you. I did the exact same thing. But instead the object won’t rotate along the x-axis.(like when you collect coins, coins rotate horizontally). Sorry if this tends to become a new topic.
After finding the specific instance using the above method. i wrote this.

``````Instantiate (prefabs[result, newTransform.position, Quaternion.Euler (45, 0, 0));
``````

But this just slants the prefab instead of rotating it.

Anyway thanks for you help.