there is nothing wrong with the code
Instantiate(projectSelecterButton,Vector3(projectSelecterXPos, projectSelecterYPos - .25, 0), Quaternion.identity);
this part : Vector3(projectSelecterXPos, projectSelecterYPos - .25, 0)
is the position where the object is created, period.
assuming you have not changed the values of projectSelecterXPos or projectSelecteryPos, the object is instantiated at Vector3(.5,.25,0), if you pause and select the object you will see this.
This is very small scale, practically (0,0,0), which is the center of the world
most likely the object you are cloning is at this position by coincidence, try moving it somewhere else, or select the object which has this script on it, and change the vars to something bigger, like 10 or 100…
EDIT:
on closer inspection, you have further issues… the use of these positions in your GUI CODE is using them as SCREEN COORDINATES, that is in terms of the screen coordinate system…
Instantiate uses a WORLD POSITION, which has nothing to do with the orientation of your camera (screen coordinates)
I can only guess that the object being instantiated is a GUIElement?
in which case you are putting it at the same position as the object which contains this script, note:
function Start ()
{
guiText.transform.position = Vector3(projectSelecterXPos,projectSelecterYPos,0);
//same as
transform.position = Vector3(projectSelecterXPos,projectSelecterYPos,0);
// in other words, this object is in the same position
}
RE-EDIT:
it seems the object you are cloning also contains this script as well, I presume… note that EVERY TIME an object with this script is created, The Start() function on that script will override any previous position, making it APPEAR to instantiate in the same place… actually, it instantiated where you wanted after all, but then instantly reset to the same place!
Yes the object being Instantiated is a GUIElement. But even if there working off a different coordinates the transform for the cloned object should be different right? But I keep getting them both the same place.
– ardizzlepress the PAUSE BUTTON select the object with THIS SCRIPT, look in the INSPECTOR, what is the position? select the CLONE, what is the position?
– Seth-BergmanI tired adding a cube and attaching the same code to it and changed the .25 to a 5 and i still have the same problem. Both cubes spawn on top of each other rather than one below the other.
– ardizzlewait a tick! the object you are cloning, does IT have THIS SCRIPT? if so, it will simply RESET ITS POSITION via ITS OWN START FUNCTION once it is created! just get rid of the line in Start() transform.position = Vector3(projectSelecterXPos,projectSelecterYPos,0);
– Seth-BergmanOh duh XD lol thanks man works perfect now. Have to love the simple mistakes lol.
– ardizzle