I am trying to instantiate a GameObject but getting “The prefab you want to instantiate is null.”
It is in the PlantedSeed.cs script. It seems to me that this should create a new instance of the PlantedSeed prefab without having to do anything in editor, but trying to fix it I’ve also tried the variable PlantedSeedPrefab to public, adding this Script to the PlantedSeed prefab, and then dragging the PlantedSeed prefab onto that area in the script (which seems wrong.)
private string variety;
private int germinationTime;
private GameObject plantedSeedPrefab;
private GameObject player;
public void Plant(string vari, int germ)
{
Debug.Log("Planting a " + vari);
//THIS IS WHERE I AM
player = GameObject.FindWithTag("Player");
PlantedSeed newSeed = (PlantedSeed) Instantiate(plantedSeedPrefab, player.transform.position + player.transform.forward, Quaternion.identity) as PlantedSeed;
newSeed.name = "seed";
newSeed.variety = vari;
Oh, I also changed the instantiation line so that PlantedSeed was GameObject, but that makes it so newSeed doesn’t have any of the variables like variety (and others I didn’t paste.)
Thanks in advance.