I have got a call to this method from a start method for one of my game objects.
public void createFirstPlatforms()
{
Debug.Log(-(basicHeight / 2));
GameObject a = Instantiate(PrePlatform, new Vector3(0.001f, -(basicHeight/2), -1.160699f), Quaternion.identity);
a.name = "Annoying_Platform";
Debug.Log(a.name + ", In position" + a.GetComponent<Platform>().GetPosition()); // GetPosition is return transform.poistion
GameObject b = Instantiate(PrePlatform, new Vector3(10.34f, 0.1215f, -1.160699f), Quaternion.identity);
b.name = "Good_Platform";
Debug.Log(b.name + ", In position" + b.GetComponent<Platform>().GetPosition()); // GetPosition is return transform.poistion
}
PrePlatform is a prefab that I have stored. I know for a fact it works as I instantiate it many more times without issue. the platforms are created with the same Z position and nothing blocks them in the position of the bad platform.
The second instantiate is working as expected but for some reason, the first one does not work when the scene starts, however, it does work when the method is called again in a restart method.
I don’t understand what events could cause it so the first Instantiate wouldn’t work when the second one does.
Using the log(image below) I know that the first platform is being Instantiated and it seems to be in the right place but it does not appear.