Question by
simplicitydown · Dec 27, 2015 at 09:46 PM ·
instantiate prefabdestroy object
Instantiating at a specific location?
I am just trying to make a square object get destroyed and have a new one instantiated in it's place. What happens now is that the first object will destroy, and the new one will appear, but it will always appear in the middle of the screen, and not in it's parent transform that holds the script. I have tried setting the vectors, using code to set the parent and a few other things but nothing works. Here, and thanks in advance!
public Transform RaisingBlock;
public GameObject lava1;
public GameObject raisedBlock1;
public GameObject loweredBlock1;
void Start()
{
StartCoroutine("MyEvent");
}
private IEnumerator MyEvent()
{
while(true)
{
yield return new WaitForSeconds(2f);
Destroy(this.gameObject);
Instantiate(lava1);
} } }
Comment
You could try this:
Instantiate(lava1, pos, transform.rotation);
where pos is the position (vector3) which you what to place the box.
It seems that you have the fixed position (parent position).
Your answer
![](https://koobas.hobune.stream/wayback/20220612054041im_/https://answers.unity.com/themes/thub/images/avi.jpg)