I have a 3D tree that I want to clone so that it is perpendicular to a planet gameobject, so it looks upright when spawned. I tried by copying down all desired rotations of the tree and adding them into a dictionary full of vector3’s so that I can access any one of them when I need to. However, using Quaternion.Euler() doesn’t copy the coordinates exactly when I pass them in; they are always wrong. Below is the code:
public void PlaceFauna(GameObject prefab, Vector3 position, Vector3 rotation, GameObject icosphere) { prefab.transform.position = position; // Moves prefab into scene and sets position prefab.transform.rotation = Quaternion.EulerAngles[rotation]; // Sets rotation to that of the one in the dictionary GameObject clone = Instantiate(prefab) as GameObject; // Creates clone clone.name = clone.GetInstanceID().ToString(); // Gives clone a unique name clone.transform.parent = icosphere.transform; // Puts clone under region prefab.transform.position = new Vector3(0, 0, 40); // Moves prefab out of scene } It takes in the position and the rotation from the dictionary and applies .Euler() to the prefab so that the tree (should) match the position. However it does not do this. Where am I going wrong?