I have a script that spawns a player when you press the play button from a different script. Everything is working fine, but the thing is the prefab isn’t showing up. Heres the code:
var playerGM : GameObject;
var startFlagPos : Vector3;
var startFlag : GameObject;
function Update () {
if (WorldEditWindow.test == true) {
startFlag = GameObject.Find("Start Flag");
if (!startFlag) {
Debug.LogWarning("There is no Start Flag in the level!");
} else {
Debug.Log("Spawning Player...");
startFlagPos = startFlag.transform.position;
Instantiate(playerGM, startFlagPos, Quaternion.Euler(0,0,0));
GameObject.Find("Main Camera").SetActive(false);
GameObject.Find("VisualizerCube").SetActive(false);
GameObject.Find("BuildGrid").SetActive(false);
GameObject.Find("BuildGridBottom").SetActive(false);
}
}
}
I tested everything, and everything is working, the start flag is being found and such, but Instantiate is just not working in general.
Ok i got it to work! What I did is that when the Start Flag is spawned, I disabled that script that I said destroys the blocks thats in the same location. So now it works perfectly!
Its funny how people (thats me) panic but then it was a very dumb mistake!