# Instantiate GameObject (149554)

**URL:** https://discussions.unity.com/t/instantiate-gameobject-149554/149554
**Category:** Questions & Answers
**Created:** [September 28, 2015, 6:07pm UTC](https://discussions.unity.com/t/instantiate-gameobject-149554/149554 "2015-09-28T18:07:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![GodOfMagic](https://avatars.discourse-cdn.com/v4/letter/g/85f322/32.png) [@GodOfMagic](https://discussions.unity.com/u/GodOfMagic)
#### Post date: [September 28, 2015, 6:07pm UTC](https://discussions.unity.com/t/instantiate-gameobject-149554/149554/1 "2015-09-28T18:07:30Z")

</div>

Hello,

I am getting error in my script where I try to instantiate game object:

```
        public int mapL, mapH;
    	public Transform[,] mapTransform;
    
    	void Start ()
    	{
    		mapL = 10;
    		mapH = 10;
    		mapTransform = new Transform[mapL,mapH];
    
    		Stuff();
    	}
    void Stuff()
    {
           mapTransform[i,j]=Transform.Instantiate(grassButton, new Vector2(i,j), transform.rotation);
    }

```

Cannot implicitly convert type UnityEngine.Object to UnityEngine.Transform. An explicit conversion exists (are you missing a cast?)

Same if I use public GameObject[,] mapTransform:  
Cannot implicitly convert type UnityEngine.Object to UnityEngine.GameObject. An explicit conversion exists (are you missing a cast?)

Can anyone tell me what I am doing wrong?

---

<div class="post-metadata">

### Author: ![Suddoha](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/suddoha/32/110358_2.png) [@Suddoha](https://discussions.unity.com/u/Suddoha)
#### Post date: [September 28, 2015, 7:20pm UTC](https://discussions.unity.com/t/instantiate-gameobject-149554/149554/3 "2015-09-28T19:20:31Z")

</div>

You can fix that by using casts (boxing or the ‘as’ keyword).

```
someTransform = (Transform)Instantiate(....);

```

or

```
someTransform = Instantiate(...) as Transform;

```

The difference is, that ‘as’ might return null when the object cannot be casted, whereas the boxing approach would throw an InvalidCastException.

---

<div class="post-metadata">

### Author: ![DCrosby](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dcrosby/32/190271_2.png) [@DCrosby](https://discussions.unity.com/u/DCrosby)
#### Post date: [September 28, 2015, 6:30pm UTC](https://discussions.unity.com/t/instantiate-gameobject-149554/149554/2 "2015-09-28T18:30:47Z")

</div>

Don’t count this as “Expert” advice, since I’m struggling with similar issues, but on the instantiating materials on the instantiated geo. But I think you’re better off doing the whole thing as a GameObject, as a transform has to have a “Parent” to live under, and GameObject is the lowest common denominator, and most likely what Unity is complaining about…
