- Home /
Why is (0,0,0) not (0,0,0)?
Awesome title, eh? Anyway, I have 3 objects. I instantiate them all at (0,0,0). They appear in 3 different places! I check their coordinates, and they're all (0,0,0). So what is going on? Has anyone else ever had anything similar? Here is my code:
function Update () {
if (numberOfBlocks > 0){
pieceNumber = Random.Range (1,4);
print (pieceNumber);
var position = Vector3(xchange,0,0);
switch (pieceNumber){
case (1):
Instantiate(straight, position, Quaternion.identity);
numberOfBlocks--;
transform.position = Vector3.zero;
break;
case (2):
Instantiate(curvePiece, position, Quaternion.identity);
numberOfBlocks--;
transform.position = Vector3.zero;
break;
case (3):
Instantiate(jump, position, Quaternion.identity);
numberOfBlocks--;
transform.position = (0,0,0);
break;
}
}
}
All the variables are right, cut them to save space.
Answer by Meltdown · May 23, 2011 at 10:27 AM
Are you using 3 different models built in a modelling tool?
If so make sure they are saved in the 3D modelling tool as being 0,0,0 in the world space and don't have any transforms applied.
This is the correct answer. (unless the value "xchange", which you apparently set somewhere externally, changes between Update()-calls). Also note that you instantiate your objects at "position" (via the Instantiate()-parameter), but afterwards you reset the transform of the GameObject your script is attached to (NOT the instantiated object) to zero each time.
Yes, this is correct I think. xchange is set to 0, but increases (so objects are produced in a line). However, I took out the changing bit to check.
Answer by demize2010 · May 23, 2011 at 10:05 AM
That's pretty funky... I suspect either your vectors aren't using 0,0,0 or for some reason it's using a value local to the instantiateing object as opposed to the world...
Edit
Where is "xchange" set? As @Meltdown points out, you may want to check the parent transform of the instanced object to make sure that it isn't going to 0,0,0 and it's the child transforms or objects that are throwing things off.
Your answer
![](https://koobas.hobune.stream/wayback/20220612083146im_/https://answers.unity.com/themes/thub/images/avi.jpg)