Hello, I’m trying for some time now to find a solution but i can’t. I have a script that allows you to spawn a game object randomly onto an empty game object. It spawns the object i want fine on the position of the empty object but the rotation is 0 0 0. How can i spawn it but use the empty game object’s rotation x y and z ?
Here is my script:
#pragma strict
var source : GameObject;
var spawnPoints : GameObject[];
function Start ()
{
var pos : Vector3 = spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position;
var instance = Instantiate(source, pos ,transform.rotation);
}
Maybe you can instantiate it first and later edit the position:
var go : GameObject = new GameObject();
This is the right way yo crate a new gameobject (a null one), using Instantiate won’t work because, this is null, and Instantiate doesn’t allow this kind of parameters