I have a cube object which holds the player script. In this script I’m loading 2 prefabs and parenting their transforms to the cube transform:
void Start () {
GameObject player_basic = Resources.Load("Models/Knight_Rig_Animations") as GameObject;
GameObject chest_basic = Resources.Load("Models/Knight_Chest_01") as GameObject;
if (player_basic != null){
player = Instantiate(player_basic);
player.transform.parent = transform;
//player.transform.localPosition = transform.localPosition;
player_chest = Instantiate(chest_basic);
player_chest.transform.parent = transform;
I want the 2 loaded prefabs to have the same position as the cube so that they will load wherever I place the cube on the terrain. However, they “spawn” far away from the cube object, and the transform pivot seems to stay at a distance “between” the cube and the 2 instantiated objects. I’ve also tried setting the prefabs localPosition to the same as the cube but it seems they instantiate on another random point, far from the parent:
How can I make these 3 objects move exactly togheter?