- Home /
Question by
AndreasX12 · Jul 14, 2013 at 03:50 PM ·
gameobjectinstantiateassign
Instantiate and then assign?
Hi, Im trying to instantiate a Transform and then assign it as a GameObject (without using .Find). This is my code:
GameObject healthgameObject = Instantiate(health, m1_enemy1_healthSpawn.transform.position, m1_enemy1_healthSpawn.transform.rotation);
But it gives me this error: Cannot implicitly convert type UnityEngine.Object' to
UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
How can this be solved?
Thanks, Andreas :-)
Comment
Best Answer
Answer by markedagain · Jul 14, 2013 at 04:06 PM
GameObject healthgameObject = Instantiate(health, m1_enemy1_healthSpawn.transform.position, m1_enemy1_healthSpawn.transform.rotation) as GameObject;