Instantiate prefab not in the correct position
I am trying to instantiate a prefab at the 0,0,0 position inside a parent object.
public static Object Instantiate(Object original, Transform parent);
The prefab appears to be in the middle of scene with the positon -2.396, 0.149 , -2.63
selected = Instantiate (myPrefab,Vector3.zero, Quaternion.identity, Selected_Assets);
Debug.Log (selected.transform.position);
selected.transform.position = new Vector3 (0, 0, 0);
Debug.Log (selected.transform.position);
Here I tried to set the positon to 0.0.0 after the instantiate but its still in the wrong position. The log saids (0.0,0.0,0.0) twice ...
I dont have any animations on the prefabs or its childeren and the prefab has the position of 0,0,0
Any ideas?
Answer by AurimasBlazulionis · Mar 28, 2017 at 03:13 PM
It still spawns in 0,0,0 global position. You should set transform.localPosition to Vector3(0,0,0). Then you might also want to set the localRotation to Quaternion(0,0,0,1).
Your answer
Follow this Question
Related Questions
Hey Guys How to make a script '**private Transform Waypoint;**', 0 Answers
Empty object spawn point's global position is wrong at first 0 Answers
Colliders have a different postion to wheels want to reset colliders to have new postion origin 0 Answers
How to make a cylinder that dynamically connects two objects? 0 Answers