Rotate a clone-object 90 degrees on spawn

I need to rotate an object that is cloned by a GameController (spawning of asteroids in a spaceshooter game)

As seen in this picture: http://i.imgur.com/biUa8at.png , I have to rotate the asteroid clones on spawn, and figured it has to be done code-wise. I’m quite sure this has to be done with a quaternion function, I just do not know which.

Here’s my GameController script:

``````using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour
{
public GameObject hazard;
public Vector3 spawnValues;

void Start ()
{
SpawnWaves ();
}

void SpawnWaves ()
{
Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x,spawnValues.x), spawnValues.y, spawnValues.z);
Quaternion spawnRotation = Quaternion.identity;
Instantiate (hazard, spawnPosition, spawnRotation);
}
}
``````

I desperately need help, I have been stuck with this problem for a great while.

The easiest thing to do would be to rotate the prefab. Then you rewrite your code to:

``````Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x,spawnValues.x), spawnValues.y, spawnValues.z);
GameObject go = Instantiate (hazard) as GameObject;
go.transform.position = spawnPosition;
``````

If you want to change the rotation for the spawn, you can do:

``````   Quaternion spawnRotation = Quaternion.Euler(90,0,0);
``````

Substitute whatever values you need for ‘90,0,0’ in the Euler().