Im getting four errors for each one of my instantiate calls:
error CS1061: Type UnityEngine.GameObject' does not contain a definition for
position’ and no extension method position' of type
UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?)
error CS1061: Type UnityEngine.GameObject' does not contain a definition for
rotation’ and no extension method rotation' of type
UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?)
error CS1502: The best overloaded method match for `UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)’ has some invalid arguments
error CS1503: Argument #2' cannot convert
object’ expression to type `UnityEngine.Vector3’
All of these relate to each of the lines that call the instantiate. The weird thing is I have one pretty much exactly the same on another script. GameObject variable = (GameObject)Instantiate() worked fine. With this script, it doesn’t like it.
Here’s the code:
switch(BombSlot)
{
case 1:
DetonateButton1.ShowBombIcon();
GameObject cloneOne = (GameObject)Instantiate(bomb, player.position + player.transform.forward * .5f, player.rotation);
Listener.audio.PlayOneShot(bomb_drop);
cloneOne.gameObject.tag = "Bomb1";
break;
case 2:
DetonateButton2.ShowBombIcon();
GameObject cloneTwo = (GameObject)Instantiate(bomb, player.position + player.transform.forward * .5f, player.rotation);
Listener.audio.PlayOneShot(bomb_drop);
cloneTwo.gameObject.tag = "Bomb2";
break;
case 3:
DetonateButton3.ShowBombIcon();
GameObject cloneThree = (GameObject)Instantiate(bomb, player.position + player.transform.forward * .5f, player.rotation);
Listener.audio.PlayOneShot(bomb_drop);
cloneThree.gameObject.tag = "Bomb3";
break;
case 4:
GameObject[] clones1 = GameObject.FindGameObjectsWithTag("Bomb1") as GameObject[];
GameObject[] clones2 = GameObject.FindGameObjectsWithTag("Bomb2") as GameObject[];
GameObject[] clones3 = GameObject.FindGameObjectsWithTag("Bomb3") as GameObject[];
Listener.audio.PlayOneShot(explosion_tech);
BombSlot = 0;
DetonateAll(clones1);
DetonateAll(clones2);
DetonateAll(clones3);
DetonateButton1.RemoveTexture();
DetonateButton2.RemoveTexture();
DetonateButton3.RemoveTexture();
break;
}
I’ve looked around for similar questions and found answers that were pretty much the same as what I have, I just dont get what the deal is.