This is my current Code for Spawning the prefab after 50 seconds the prefab spawns but the game crashes straight after.
using UnityEngine;
using System.Collections;
public class BossSpawn : MonoBehaviour
{
public GameObject Boss;
GameObject bossClone;
void Start ()
{
StartCoroutine(WaitSpawner());
}
IEnumerator WaitSpawner()
{
yield return new WaitForSeconds(50f);
Debug.Log("it has been 50sec");
bossClone = Instantiate(Boss, transform.position, Quaternion.identity) as GameObject;
}
void Update () {
}
}
This is the Error I get
UnassignedReferenceException: The variable Boss of BossSpawn has not been assigned.
You probably need to assign the Boss variable of the BossSpawn script in the inspector.
UnityEngine.Object.Internal_InstantiateSingle
Heya, thank you for the help! It is the first time I have coded so I am very much a beginner. When you say Assign do you mean assigning the Tag Boss to the Prefab? Or do you mean something else?
Like I said, it is hackish.
What it does is validate if the attribute boss has been assigned before attempting to spawn it.
The non-hack fix would be to figure out why you have a gameobject attempting to spawn a boss without the attribute being assigned.