I’m finding it hard to believe you can’t instantiate a prefab game object from code without dragging the prefab into an already existing object to give it the reference. However, that’s the only instructions I’m seeing online.
Example from Unity - Manual: Instantiating Prefabs at run time
// Reference to the Prefab. Drag a Prefab into this field in the Inspector. public GameObject myPrefab;
I don’t want to drag anything. In code only, I simply want to create a game object and then set it to the prefab, or create the prefab which inherently makes the game object. Something like this:
GameObject player;= new Prefab("Player1.prefab"); player.name = "Player 1"; player.transform.position = new Vector3(0, 0, 0);
Does this functionality exist? If not, I’m left with creating my game object line by line in my code.