- Home /
 
 
               Question by 
               TimBorquez · Mar 26, 2013 at 06:17 PM · 
                gameobjectinstantiatetransform.position  
              
 
              How do I instantiate on the game object's position that i put the script on
ok so i am instantiating an object in a .js script
i made an empty game object so it can be my spawn point
i threw the script on the game object and no matter what i do it is just instantiating in the middle of the world
here is the last thing i tried:
 var currentPosition = Vector3(transform.position.x, transform.position.y, transform.position.z)
 
 function Update () {
      var instance : GameObject = Instantiate(Resources.Load("fake toy"), currentPosition, transform.rotation);
 }
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Josh707 · Mar 26, 2013 at 06:53 PM
I would'nt use instantiate in the update function as you're creating a new object every frame. Anyways, below that just write something like this:
 var instance : GAmeObject = Instantiate(...);
 
 instance.transform.position = currentPosition;
 
              thank you! and yeah i actually had the instatiate in an if statement i just didnt think it was relevant
ended up doing this:
  var instance : GameObject = Instantiate(Resources.Load("fake toy"));
 
 instance.transform.position = transform.position;
 
                  I didnt think about changing the instance after i made it like that for some reason...
Your answer