- Home /
My objects instantiate at a strange z coordinate
I am instantiating a prefab which contains the word "GAME". I have created the prefab so that its position is (0,400,0).
When I instantiate it using:
GameText = Instantiate(Resources.Load("GameOver1"), new Vector3 (gameX, gameY, gameZ), Quaternion.Identity) as GameObject;
It spawns the object at the correct x and y coordinates, but at a Z of -997. The vector that is shown in the instantiation is new Vector3(0,350,1).
Because of this strange result I have tried changing what I instantiate, as well as instantiating it from the scene rather than the resource folder, but I still have no luck.
I then want to transform it to a new position over time, which appears to work as a scaled version of what I want, and funnily enough that scale is 997 times larger than I want.
On the plus side this is better than it used to be where it would spawn at random x,y and z coordinates.
Let me know if there are any attachements that would be useful to troubleshoot this problem.
Please add the following immediately before your instantiate line. What does it print?
Debug.Log("X:" + gameX + ", Y:" + gameY + ", Z:" + gameZ);
Debug log shows x = 0, y = 352, and z =1 which is what it should be, yet it still instantiates at z = -997 :/