Instantiating gameobject without getting global rotation

Hello!

I am working on a spawnscript where I instantiate my gameobjects (meteors) at random index in an array of empty gameobjects (spawnpoints). I want the spawned object to get the same position and rotation of the picked spawnpoint. The object is instantiated at the correct position but with the spawnpoints GLOBAL rotation. I want the local rotation, how can I fix this?
Here is the code:

private var spawnPoints : GameObject[];
private var spawnPointATM : int;

private var randomMeteor : int = 0;

public var bigMeteor : GameObject;
public var mediumMeteor : GameObject;
public var smallMeteor : GameObject;
private var copyMet : GameObject;

private var speed1 : float = 5;
private var speed2 : float = 40;
private var speed3 : float = 200;

private var timer : float = 0.0;
public var spawnTime : float = 5;

function Start () {
	spawnPoints = GameObject.FindGameObjectsWithTag("MeteorSpawnPoint");
}

function Update () {
	
	if(timer < Time.time){
		spawnPointATM = Random.Range(0, spawnPoints.Length);
		timer = Time.time + spawnTime;
		randomMeteor = Random.Range(1, 4);
		Debug.Log(randomMeteor.ToString());
		
		if(randomMeteor == 1){
		copyMet = Instantiate(bigMeteor.gameObject, spawnPoints[spawnPointATM].transform.position, spawnPoints[spawnPointATM].transform.rotation);
		//copyMet.transform.rotation = spawnPoints[spawnPointATM].transform.rotation;
		copyMet.gameObject.rigidbody.AddForce(Vector3.forward * speed1);
		
		Destroy(copyMet, 160);
		}
		
		if(randomMeteor == 2){
		copyMet = Instantiate(bigMeteor.gameObject, spawnPoints[spawnPointATM].transform.position, spawnPoints[spawnPointATM].transform.rotation);
		copyMet.gameObject.rigidbody.AddForce(Vector3.forward * speed2);
		
		Destroy(copyMet, 160);
		}
		
		if(randomMeteor == 3){
		copyMet = Instantiate(bigMeteor.gameObject, spawnPoints[spawnPointATM].transform.position, spawnPoints[spawnPointATM].transform.rotation);
		copyMet.gameObject.rigidbody.AddForce(Vector3.forward * speed3);
		
		Destroy(copyMet, 160);
		}
		}
	
}

Thanks!!

At first that didn’t change anything but then I found: this.gameObject.rigidbody.AddForce(Vector3.forward * speed);
on a script attached to the meteor at the start function. So after changing that it works perfect! Not sure if that simply was the problem all along :stuck_out_tongue_winking_eye: Thank you so much for the help! Please change it to a question so that I may approve it :slight_smile: