I keep receiving this error when I try to instantiate a prefab. Yes, I have linked prefab to the GameObject inside the C# script and yet it still gives me this error. Yes I have tried Resource.Load as well and that also failed. The prefab is in my assets folder. this is my code so far.
public class Surface : MonoBehaviour
{
public GameObject SurfacePrefab;
public List<Entity> Players;
void Start ()
{
Players = new List<Entity>();
Instantiate(SurfacePrefab);
Entity Player = new Entity();
Player.CreateGameObject();
Players.Add(Player);
}
void Update()
{
}
}
Player.CreateGameObject(); is where the exception occurs.
public void CreateGameObject()
{
Instantiate(EntityPrefab, Position, Quaternion.identity);
}
And EntityPrefab is linked to the prefab which is just a sphere.